Excel 2016 VBA Hyperlinks Problem to Index sheet

claywhit

New Member
Joined
Sep 5, 2016
Messages
8
Appreciate help with understanding how a VBA macro that works fine in Excel 2010 and 2013, but that generates an error (Run-time error '1004': Application-defined or object-defined error) when executing in version 2016 explicitly.


The macro is embedded with a sheet in a workbook (the "Index" sheet), rather than as a module. The indexing hyperlink feature seems common with workbooks containing large numbers of worksheets. I've tried looking through the forum for exact same problem but couldn't find so I'm hoping I can find a solution on the forum.


The snippet below shows the area of issue in the code. wSheet is dimensioned as a worksheet variable at the start of the program and is used to cycle through the various spreadsheets in the workbook. A test (not shown) is first conducted to ensure the Index sheet itself is not included in the rotation. The program halts with the error mentioned above at the ".Hyperlinks.Add..." line.




With wSheet
.Range("A1").Name = "Start_" & wSheet.Index 'Sets up naming A1 cell in each spreadsheet tab

'Hyperlink lines below writes the hyperlink in each spreadsheet tab with reference back to Index sheet
.Hyperlinks.Add Anchor:=.Range("A1"), Address:="", _
SubAddress:="Index", TextToDisplay:="INDX"

End With


I've tried various things like a ".Activate" after the ".Range" line, but to no avail. What does work is if I do a manual controlled hyperlink addition that doesn't use the wSheet variable.


Sheets.Add.Name = "Test1"
Sheets("Test1").Range("A1").Value = "Hi"
Sheets("Test1").Range("A1").Name = "HiName"
Sheets("Test1").Hyperlinks.Add Anchor:=Sheets("Test1").Range("A1"), Address:="", SubAddress:="Index", TextToDisplay:="INDX"


Any suggestions or answers regarding why I'm not having this issue in version 2016?
Thanks,
Clay
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

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