I have a workbook with two sheets. I have one macro that saves the text of the active cell in sheet 1 for later use, the macro then switches to sheet 2 and using the find function I want it to search for the variable I just setup but I keep getting run-time error 91.
Here is what I have:
'First, I hand select the correct "terminal number" from sheet1 and store it's text and address
TerminalRng = ActiveCell.Address
TerminalStr = ActiveCell.Value
'To check my variables are correct
MsgBox "Terminal Range : " & TerminalRng
MsgBox "Terminal Text : " & TerminalStr
Sheets(2).Select
MsgBox "Terminal on Sheet2 check : " & TerminalStr 'To make sure the variable is still valid after switching to sheet2
Cells.Find(What:=TerminalStr, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
I get the run-time error 91 with the Find lines of code yellow and the arrow pointing at the last row. I've tried all kinds of variations (with and without Activate) of the find function and as long as it is searching in sheet2 for the variable that was made in sheet1 it will NOT work. If I do this same search on Sheet1 I get no error. Also if I change the string name in Find to the same exact text just with quotes on it it will find that text without problem in Sheet2. But if I use a string I get an error. So frusterating! I'm not even doing anything that complex.
Once I get this to work I want to save the address where the string is found in Sheet2 and use that address later as well so some advice on how to get an address from a Find result would be great as well.
Can someone help?
Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
Bookmarks