Reputation: 546
I am trying to loop through a range and search another range if value meets if
statement criteria. I want a msgbox to appear if search fails. I'm stuck on how to set the criteria for the search failings though.
Dim r2 As Range
For Each r2 In WorkRng2
If r2.Offset(0, 1).Value <> 0 Then
WorkRng1.Find what:=r2.Value, LookIn:=xlValues
WorkRng2
is a public range variable.
How do I finish this code to warn user search failed?
Upvotes: 0
Views: 79
Reputation: 14373
Find
find s a range - or not. Therefore ...
Dim Fnd As Range
Set Fnd = WorkRng1.Find(what:=r2.Value, LookIn:=xlValues)
If Fnd Is Nothing Then
' Nothing found
Else
' Fnd holds the cell that was found
End If
Upvotes: 1