daniel22bg
New Member
- Joined
- Nov 21, 2008
- Messages
- 31
Hello, i have the following piece of VBA code, enclosed at the bottom. I would like to search for a word in the whole row. If the word is found, i would like select and hide the row, if the word is not found, I would like to proceed with the next row.
However, whenever the word is not found, I get and error ... Can you please help? In what way can handle the error situation or the situation where the word is not found in the row?
However, whenever the word is not found, I get and error ... Can you please help? In what way can handle the error situation or the situation where the word is not found in the row?
Code:
For i = 3 To k
Rows(i).Select
Selection.Find(What:=SearchVar, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select
Set rFound = Selection
If Not rFound Is Nothing Then
rFound.EntireRow.Hidden = True
End If
Next i