Problem adding hyperlink in VBA

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
15,507
Office Version
  1. 365
Platform
  1. Windows
Hi all, Does anyone have an idea how I can make this work?

Code:
ActiveSheet.Hyperlinks.Add Anchor:=Cells(b, c - 1), Address:="", SubAddress:=Cells(b, c - 1), TextToDisplay:=d

I want to link the cell to itself with the hyperlink, (yes there is a reason for it) this line works with Range but not Cells, unfortunately both variables return integers so I need to somehow convert the numeric value of the varaible "c" to the corresponding column.

I'm sure it should be an easy and obvious task but I've been looking at code all day and can't see it :confused:

Thanks in advance

JB
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I'm still at a loss on this one, it could be that the error is elsewhere in the code, as I checked some other code I have that creates hyperlinks and that works with Cells.

I've tried this (looks messy) all variables are giving the correct information, but I'm getting a runtime error 5 on the hyperlink line
Code:
e = Array("A", "B", "C", "D", "E", "F", "G", "H")
ActiveSheet.Hyperlinks.Add Anchor:=Cells(b, c - 2), Address:="", SubAddress:=Range("'Control_Sheet'!" & e(c - 2) & b), TextToDisplay:=d
Current variable values from mouseover code at error
b = 3
c = 2
e = "A"
All varaibles appear to be producing valid results for the code to work.

Any ideas?

Jason
 
Upvote 0
Case closed

Rich (BB code):
ActiveSheet.Hyperlinks.Add Anchor:=Cells(b, c - 2), Address:="", SubAddress:=Range("'Control_Sheet'!" & e(c - 2) & b), TextToDisplay:=d

I was trying to link to cell content, not cell address, deleting the red text solved it.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top