PDA

View Full Version : Solved: hyperlink question



vzachin
08-14-2008, 02:14 PM
hi,

as i add a new sheet, i place the newly added sheet name into column a of another sheet named "trackin".
i want to add a hyperlink each time i add a new sheet.

this is what i have but i get a "reference is not valid"
how do i reference this correctly?

thanks
zach


Sub test()
With Sheets("trackin")
rw = Sheets("trackin").Cells(Rows.Count, "a").End(xlUp).Row
shnm = .Range("a" & rw)
.Range("a" & rw).Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"shnm!A1", TextToDisplay:=shnm
End With

End Sub

vzachin
08-14-2008, 06:17 PM
figured it out! whew!
With Sheets("trackin")
rw = .Cells(Rows.Count, "a").End(xlUp).Row
Set shnm = .Range("a" & rw)
shnm.Hyperlinks.Add shnm, "", "'" & shnm & "'!A1"
End With