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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
All,

After further testing, it appears that the 2016 "hyperlinks.add" problem occurs if the worksheet I'm attempting to write the hyperlink into is protected. The cell itself is not locked or hidden in the locked worksheet, but unless I first unprotect the worksheet itself, then the VBA program crashes in version 2016, but not in 2013 or 2010. Are there specific Excel 2016 program options to resolve the matter? I know I could unprotect and then reprotect the worksheet, but just wondering what others may have done.

Thanks,
Clay
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,344
Members
449,219
Latest member
Smiqer

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