Forum Discussion
PeteSW
Oct 16, 2025Copper Contributor
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(...
m_tarler
Oct 16, 2025Bronze Contributor
to do it in a macro the code would be like:
ActiveWorkbook.Sheets(n).Activate
where n is the sheet number
- PeteSWOct 22, 2025Copper 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