[Solved] Excel VBA Macro to search a column and display rows in pop up message based on column value [closed]


Based on what you’ve told me, this is what I can provide. Running it will find the first occurrence where Column A is not blank and Column B is missing text. You can then have your user fill it in, run it again to check for more.

Sub checkcolumns()
Dim i As Long

'100 is the last row you want to check. Change accordingly

For i = 1 To 100       
    'Change Sheet1 to your worksheet name
    If ActiveWorkbook.Worksheets("Sheet1").Range("A" & i).Value <> "" And ActiveWorkbook.Worksheets("Sheet1").Range("B" & i).Value = "" Then
        MsgBox "Row " & i & " is missing a value in column B!", vbExclamation, "Missing value!"
        Exit Sub
    End If
Next i

MsgBox "Search complete, all values are in place!", vbInformation, "Success!"
End Sub

To display all in one message:

Sub checkcolumns()
Dim i As Long
Dim message As String

For i = 1 To 100
    If ActiveWorkbook.Worksheets("Sheet1").Range("A" & i).Value <> "" And ActiveWorkbook.Worksheets("Sheet1").Range("B" & i).Value = "" Then
        message = message + "Row " & i & " is missing a value in Column B! "
    End If
Next i

MsgBox message, vbInformation, "Success!"
End Sub

3

solved Excel VBA Macro to search a column and display rows in pop up message based on column value [closed]