Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 90251

Filling a specific column based on user inputs and tracking result

$
0
0

I have range of products that are routinely tested every quarter, each product is tested once annually.

I need an excel VBA that prompts the user to input what product was tested and then prompt the user to input in which quarter (e.g. Q1,Q2 etc ) the product was tested. Then in a specific column this information about which quarter the product is tested is displayed and inputted into a cell.

I then want to be able to keep track of this information about which quarter each product was tested every year so for the next test for each product, would like excel to fill the row next to it. Shown below is an visual example of what I'm trying to achieve.

Example of Excel Worksheet

Also attached is the code I have been trying mould to fit my problem.

Sub CommandButton1_Click()

 Dim myValue As Variant

myValue = InputBox("Give me some input")

Dim SearchString As String
Dim SearchRange As Range, cl As Range
Dim FirstFound As String
Dim sh As Worksheet

' Set Search value
SearchString = myValue
Application.FindFormat.Clear
' loop through all sheets
For Each sh In ActiveWorkbook.Worksheets
    ' Find first instance on sheet
    Set cl = sh.Cells.Find(What:=SearchString, _
        After:=sh.Cells(1, 1), _
        LookIn:=xlValues, _
        LookAt:=xlPart, _
        SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, _
        MatchCase:=False, _
        SearchFormat:=False)
    If Not cl Is Nothing Then
        ' if found, remember location
        FirstFound = cl.Address
        ' format found cell
        Do
            cl.Font.Bold = True
            cl.Interior.ColorIndex = 3
            ' find next instance
            Set cl = sh.Cells.FindNext(After:=cl)
            ' repeat until back where we started
        Loop Until FirstFound = cl.Address
    End If
Next
End Sub

Viewing all articles
Browse latest Browse all 90251


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>