ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hyperlinks with Cells(r,c).Value reference (https://www.excelbanter.com/excel-programming/405686-hyperlinks-cells-r-c-value-reference.html)

KS

Hyperlinks with Cells(r,c).Value reference
 
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!


All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com