I am trying to execute what i think should be a fairly simple command, but i'm having a tough time getting it to work the way I want. I want the program to follow the selected cells reference and select that. Essentially exactly the same function as the CTRL+[ shortcut. I tried to just record that shortcut, but to no avail.
Sub Macro()
'
' Macro when i record “Ctrl+[“
'
Application.Goto Reference:="'Sheet2'!R[1048550]C[16366]"
End Sub
This just takes me to a random cell on the sheet i was trying to reach. If i change this to read R[0]C[0], it takes me to the same cell but on the new sheet (Sheet1!B3 to Sheet2!B3, for example) regardless of where the original cell is referenced to.
I did some searching on the net, and found someone with the same problem as me from a few years ago. However there was no working solution posted to his question that i could uncover. This is the code he found, but niether he or I could get it to work. It's a bit beyond my VBA ability to effectively analyze what this is doing and fix it.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim strSheet As String
'On Error Resume Next
If InStr(1, Target.Formula, "!") Then
If InStr(1, Target.Formula, "'") Then
strSheet = Mid(Replace(Target.Formula, "'", ""), 2, InStr(1, Target.Formula, "!") - 4)
Else
strSheet = Mid(Target.Formula, 2, InStr(1, Target.Formula, "!") - 2)
End If
Sheets(strSheet).Activate
ActiveSheet.Range(CStr(Right(Target.Formula, Len(Target.Formula) - InStr(1, Target.Formula, "!")))).Select
End If
End Sub
Any help would be greatly appreciated! I'm sure there is a simple fix for this, but i couldn't uncover it.
Bookmarks