I am learning VBA. I have a following code, in line 6 if the condition meets, I want the excel to display pop up window mentioning the value of cells(x,4) along with highlighting it in Red. If there are multiple items which meet this condition then its fine if it display one message box for each condition met.
I tried msgbox " cells(x,4) & is a best ship date " but its not pulling the value of cell.
Sub test()
Dim lRow As Long
Dim x As Long
lRow = Cells(Rows.Count, 5).End(xlUp).Row
For x = 2 To lRow
If Cells(x, 4) = "Best Ship Date" Then
Cells(x, 6).Interior.Color = vbRed
ElseIf Cells(x, 6) >= Cells(x, 5) Then
Cells(x, 6).Interior.Color = vbGreen
Else
Cells(x, 6).Interior.Color = vbYellow
End If
Next x
End Sub
Bookmarks