Forum Discussion
Reference sheet numbers in hyperlink
I want to be able to link a specific shape to a sheet by the sheet number, not its name.
Using the standard method, by selecting 'hyperlink', only a list of sheet names appear.
Inserting a onclick() macro into the initial sheet would work but I cannot figure out how to reference a sheet by its number.
All help appreciated.
3 Replies
- PeteSWCopper Contributor
Thank you for your response. I will try it out when I return to my office next week.
- m_tarlerBronze Contributor
to do it in a macro the code would be like:
ActiveWorkbook.Sheets(n).Activate
where n is the sheet number
- PeteSWCopper Contributor
Your solution works, as expected. But only partially!
Below is a series of basic macros I have included in my work book.
The first two (101 and 102) work perfectly, however the others give 'subscript out of range' error.
All were created by copying the first one. The rectangle and sheet numbers have been checked multiple times, but I cannot see any fault.
Any ideas?
Sub Rectangle101_Click() ActiveWorkbook.Sheets(23).Activate End Sub Sub Rectangle102_Click() ActiveWorkbook.Sheets(24).Activate End Sub Sub Rectangle103_Click() ActiveWorkbook.Sheets(36).Activate End Sub Sub Rectangle104_Click() ActiveWorkbook.Sheets(37).Activate End Sub Sub Rectangle105_Click() ActiveWorkbook.Sheets(38).Activate End Sub Sub Rectangle106_Click() ActiveWorkbook.Sheets(39).Activate End Sub