Hyperlink macro for personal.xls

A

al007

Sub Hyperlinkcell()
'
Dim actual As Range

Set actual = Application.InputBox(Prompt:="Select cell to
hyperlink.", Type:=8)
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="",
SubAddress:=actual, TextToDisplay:=ActiveCell.Value
End Sub

Can anybody fix the above hyperlink macro pls.

Thxs
 
N

Norman Jones

Hi Al007,

Try:

'=============>>
Public Hyperlinkcell()
Dim actual As Range

Set actual = Application. _
InputBox(Prompt:="Select cell to hyperlink.", _
Type:=8)
'

ActiveSheet.Hyperlinks.Add _
Anchor:=Selection, _
Address:="", _
SubAddress:=actual.Address(0, 0)
End Sub
'<<=============
 
A

al007

Thxs - but it does not work if a cell from a different sheet is
selected - can you help pls
 
T

Tom Ogilvy

Sub Hyperlinkcell()
'
Dim actual As Range

Set actual = Application.InputBox( _
Prompt:="Select cell to hyperlink.", Type:=8)
ActiveSheet.Hyperlinks.Add _
Anchor:=Selection, _
Address:="", _
SubAddress:="'" & actual.Parent.Name & _
"'!" & actual.Address(0, 0), _
TextToDisplay:=actual.Text
End Sub
 
T

Tom Ogilvy

Here is a slight revision

Sub Hyperlinkcell()
'
Dim actual As Range
Dim Act_Cell as Range
set Act_Cell = ActiveCell
Set actual = Application.InputBox( _
Prompt:="Select cell to hyperlink.", Type:=8)
ActiveSheet.Hyperlinks.Add _
Anchor:=Act_Cell, _
Address:="", _
SubAddress:="'" & actual.Parent.Name & _
"'!" & actual.Address(0, 0), _
TextToDisplay:=actual.Parent.Name & _
"!" & actual.Address(0, 0)
End Sub
 
A

al007

Thxs tom,
Your code is working great & am using it for empty cells & using
SubAddress:=activecell.value for non empty cells with an if statement
cheers!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top