Formatting a cell as a hyperlink

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
 
G

Guest

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.
 
B

Bill Murphy

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.
 

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