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
 

Forum statistics

Threads
1,081,578
Messages
5,359,736
Members
400,545
Latest member
Damntheman30

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top