Hyperlink to Same Workbook in Loop

campbesj7

New Member
Joined
Feb 25, 2016
Messages
8
Hi there, I am trying to create a hyperlink to each line of a list of titles that are produced through a While loop.

The below code works fine, but does not allow for the Anchor and SubAddress to be adjusted with each iteration of the loop.

ActiveSheet.Hyperlinks.Add Anchor:=Cells(3, 2), Address:="", SubAddress:= _
"Sheet1!A570", TextToDisplay:="DD"

Here is the full code that I am trying to get be able to follow with the loop

Dim LabelStart As Integer
Dim LabelOffset As Integer
Dim LabelName As String
Dim ListNum As Integer

LabelStart = 2
ListNum = 2
LabelName = Sheets("Model").Cells(ActiveCell.Row, 5) 'LabelName is edited for each iteration in a step not shown here

Sheets("Charts").Activate
LabelOffset = LabelStart + 26
ActiveSheet.Hyperlinks.Add Anchor:=Cells(LabelStart, 1), Address:="", _
SubAddress:=Cells(LabelOffset,1) _
TextToDisplay:=LabelName

'To Increase for next iteration of loop
LabelStart = LabelStart + 27
ListNum = ListNum + 1

I also get a 'Compile Error' for the TextToDisplay line and I can't figure out how fix it. Any help would be greatly appreciated!
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,215,516
Messages
6,125,284
Members
449,218
Latest member
Excel Master

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