I am trying to use GoTo address a cell on a different worksheet. I used GoTo because I didn't want to make sheet2 active. The code used was:
Application.GoTo Reference:=Sheets("Sheet2").Range("CellLoc")
The variable CellLoc come form a sub that returns the cell address if a value is found in a range. The code is shown below:
Sub X()
Dim rngX As Range
Dim CellLoc As Variant
Set rngX = Sheets("Sheet2").Range("B2:B10000").Find(What:=Sheets("Sheet1").Range("B4"), lookat:=xlPart)
If Not rngX Is Nothing Then
'MsgBox "Found at " & rngX.Address
CellLoc = rngX.address(False,False)
End If
End Sub
The value CellLoc is returned properly and the code compiles correctly, however, I receive an error at:
Application.GoTo Reference:=Sheets("Sheet2").Range("CellLoc")
when I run the sub. Does anyone have a suggestion to fix this?
Thanks,
Art
Bookmarks