PDA

View Full Version : Solved: Followhyperlink code



akamax_power
06-12-2008, 09:13 AM
How can i get the following code to work under the sheet followhyperlink sub. I keep getting an "object does not support method" error for the i = Mid(...)


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
With Target
If Target.TextToDisplay = "GoTo" Then
Dim sht As String
Dim i As Integer
Dim idstr As String

i = Mid(Range("A" & Target.Row).Value, 5, 1)
idstr = "2,1," & i
With Sheets("Project Summary")
sht = .Cells.Find(what:=idstr).Offset(0, 2).Value
End With

Sheets(sht).Activate
End If
End With
End Sub

mdmackillop
06-12-2008, 09:37 AM
Try this
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
With Target.Range
If .Text = "GoTo" Then
Dim sht As String
Dim i As Integer
Dim idstr As String
i = Mid(ActiveSheet.Range("A" & .Row), 5, 1)
idstr = "2,1," & i
With Sheets("Project Summary")
sht = .Cells.Find(what:=idstr).Offset(0, 2).Value
End With
Sheets(sht).Activate
End If
End With
End Sub

End Sub

akamax_power
06-12-2008, 10:09 AM
Thanks, works perfectly