Hyperlinks with Cells(r,c).Value reference

K

ks

I am trying to update hyperlinks via VBA after I added a hyperlink base to
the excel file properties. I can't figure out why the following code breaks
when I try to assign cellValue for the first time.

====================

Sub SetHyperlinks()

Dim r, c, z As Integer
Dim hyp As Hyperlink
Dim cellValue As Variant

Worksheets("LOG").Select
c = Application.InputBox(prompt:="Enter the column that contains the
hyperlinks to set:")

r = Application.InputBox(prompt:="Enter the row to set to #1:")

z = Application.InputBox("How many hyperlinks to create:")

z = z + r

Do While r <= z
cellValue = ActiveSheet.Cells(r, c).Value ** Object-defined error
here **
If IsNull(cellValue) Then cellValue = " "
ActiveSheet.Hyperlinks.Add Anchor:=ActiveSheet.Cells(r, c),
Address:="Num-" & r & ".pdf", TextToDisplay:=cellValue
r = r + 1
Loop
End Sub

===============

Thanks for any help!
 

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