Formatting a cell as a hyperlink

  • Thread starter Thread starter Bill Murphy
  • Start date Start date
B

Bill Murphy

In my Access application I create and format Excel files using Excel
automation.
Is there a way to format a column in a spreadsheet as a hyperlink using
Visual Basic? For example if a column contains the text
j:\images\myimage.tif, can this be formatted as a hyperlink when the Excel
file is being created and formatted using VBA?

Bill
 
Let us assume that the text in the cells in column A are legal hyperlink
destinations. Then:

Sub hyper_maker()
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Set r = Cells(i, "A")
v = r.Value
r.Clear
ActiveSheet.Hyperlinks.Add Anchor:=r, Address:=v, TextToDisplay:=v
Next
End Sub

may do what is needed.
 
Thanks for your help.

Bill

Gary''s Student said:
Let us assume that the text in the cells in column A are legal hyperlink
destinations. Then:

Sub hyper_maker()
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Set r = Cells(i, "A")
v = r.Value
r.Clear
ActiveSheet.Hyperlinks.Add Anchor:=r, Address:=v, TextToDisplay:=v
Next
End Sub

may do what is needed.
 
Back
Top