Okay, so I was trying to make a particular method work more efficiently by using the Find method rather than a loop, and yes, when I use this totally by itself it works TONS better and faster.
Here is the portion of code of reference:
It comes immediately after another portion which chooses the last cell with any values in it in column A.
When I run this code in a module totally to its own, it has no problems and works just fine.
However, when I have it following the other code, as mentioned, it gives me this error:
So, my problem is: why in the world does it only happen under certain conditions? It is the EXACT same code whether by itself or in another procedure.
I found the code first here:
Then, I decided to troubleshoot by recording a macro and getting it directly from Excel - it came out the same, basically.
Surely, one of the experienced gurus around here has a clue on this one.![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
--
"If to err is human, then I must be some kind of human!" -Me
Here is the portion of code of reference:
Code:
Cells.Find(What:="Unique ID", After:=Cells(1, 1), LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False).Activate
It comes immediately after another portion which chooses the last cell with any values in it in column A.
When I run this code in a module totally to its own, it has no problems and works just fine.
However, when I have it following the other code, as mentioned, it gives me this error:
Run-time error '91':
Object variable or With block variable not set
So, my problem is: why in the world does it only happen under certain conditions? It is the EXACT same code whether by itself or in another procedure.
I found the code first here:
Then, I decided to troubleshoot by recording a macro and getting it directly from Excel - it came out the same, basically.
Surely, one of the experienced gurus around here has a clue on this one.
![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
--
"If to err is human, then I must be some kind of human!" -Me