Creating HyperLinks in VB
Max,
Sorry. I meant to post the code as well.
Alan
Sub test5()
Dim strEngine
Dim i
i = 4
Sheets(2).Cells(i + 5, 2).Value = "strEngine"
Sheets(2).Cells(i + 5, 2).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:= _
"'" + Sheets(2).Cells(i + 5, 2).Value + "'!A1", _ '<<<<<<
Inserted Cell reference.
TextToDisplay:=Sheets(2).Cells(i + 5, 2).Value
With Cells(i + 5, 2).Font
.Name = "GE Inspira"
.FontStyle = "Regular"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = True
.Underline = xlUnderlineStyleSingle
.ColorIndex = 5
End With
End Sub
Max wrote:
Thanks for the help!
I made the suggested changes - and really, it's a matter of preference...
But I'm still getting errors.
Yes, strENGINE is a variable that is previously used to name a sheet. When
I run, no erros. But when I try and click the hyperlink, I get the following
error:
"Your formula contains an invalid external reference to a worksheet. Verify
that the path, workbook, and range name or cell reference are correct, and
try again."
Here's the kicker, when I just insert a hyperlink, the path that it
generates and displays when I hover over the link is EXACTLY THE SAME!!!
What am I missing?
Here's what I have now:
Sheets(2).Cells(i + 5, 2).Value = strENGINE
Sheets(2).Cells(i + 5, 2).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"'" + Sheets(2).Cells(i + 5, 2).Value + "'!",
TextToDisplay:=Sheets(2).Cells(i + 5, 2).Value
With Cells(i + 5, 2).Font
.Name = "GE Inspira"
.FontStyle = "Regular"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = True
.Underline = xlUnderlineStyleSingle
.ColorIndex = 5
End With
--
Thanks!
Max
"Dennis" wrote:
Forgot the final "+" sign in:
"'" + Sheets(2).Cells(i + 5, 2).Value + "'!"
GL EagleOne
|