tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,834
- Office Version
- 365
- 2019
- Platform
- Windows
Is it possible to find a value that is not on the active sheet?
If Sheet1 is the activesheet and contains the value, "somevalue" the above will run.
However if Sheet2 is the activesheet, the above will crash.
How can I amend the code so it will work without having to select Sheet1 first?
Thanks
Code:
Sheet1.Cells.Find(What:="somevalue", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Sheet1 is the activesheet and contains the value, "somevalue" the above will run.
However if Sheet2 is the activesheet, the above will crash.
How can I amend the code so it will work without having to select Sheet1 first?
Thanks