sulakvea,
thanks but that didnt work. the MsgBox didnt appear, even though cell M3 didnt contain CNF.
my data will be a dynamic number of rows (always changing), how do i make sure the code is only looking at rows with data and not all 65536 rows?
also my searchable data is from cell M2 downwards, as cell M1 is column header "System Status", so i need to search from cell M2 downwards.
thanks![]()
Sub CNF()
Dim i As Long
Dim LASTROW As Long
LASTROW = Cells(Rows.Count, 13).End(xlUp).Row
For i = LASTROW To 2 Step -1
Sheets("Sheet2").Select
If Range("M" & i) <> "CNF" Then
MsgBox ("System Status must contain CNF")
Exit Sub
End If
Next i
End Sub
Dim i As Long
Dim lngLastRow As Long
lngLastRow = Cells(Rows.Count, "M").End(xlUp).Row
For i = 1 To lngLastRow
If InStr(Range("M" & i).Value, "CNF") > 0 Then
' "CNF" found in cell
Else
' "CNF" not found in cell
MsgBox Range("M" & i).Address & " System Status must contain CNF"
End If
Next i