"Object variable not set"??
I'm using Find in:
Dim MyTarget As String
Dim rngSearch As Range
Dim thisRow As Long
<< other stuff
thisRow = ActiveCell.Row
Set rngSearch = Range("A" & thisRow & ":AA" & thisRow)
rngSearch.Select
If Selection.Find(What:=MyTarget _
, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows _
, SearchDirection:=xlNext, _
MatchCase:=False).Activate Then
The IF statement generates the "Object variable or With block variable not
set" error. But I use this same code in another macro as:
ws1.Activate
rngSearch.Select
If Selection.Find(What:=strTIR _
, After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows _
, SearchDirection:=xlNext, _
MatchCase:=False).Activate Then
(In this case, there are two workbooks, and I have to activate the one I
want to search. In the first code, I am using only one workbook.)
Any suggestions?
Ed
|