Keep leading zero on Hyperlinks

Djro69

New Member
Joined
Nov 2, 2020
Messages
11
Office Version
  1. 2019
Platform
  1. Windows
Hi - using this code, is there a way to keep the leading zero on e.g. a worksheet called 090000 so the hyperlink is 090000 and not just 90000.

Many thanks in advance.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Sub Test()

Dim mySheet As Worksheet, myRow As Long
With Sheets("Summary")
.Range("A:A").Clear
myRow = 3
For Each mySheet In ActiveWorkbook.Worksheets
If mySheet.Name <> "Summary" Then
.Hyperlinks.Add Anchor:=.Cells(myRow, 1), Address:="", SubAddress:= _
"'" & mySheet.Name & "'!A1", TextToDisplay:=mySheet.Name
myRow = myRow + 1
End If
Next mySheet
End With
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
How about
VBA Code:
If mySheet.Name <> "Summary" Then
   .Hyperlinks.Add Anchor:=.Cells(myRow, 1), Address:="", SubAddress:= _
   "'" & mySheet.Name & "'!A1", TextToDisplay:="'" & mySheet.Name
   myRow = myRow + 1
End If
 
Upvote 0
Solution
Perfect - many thanks for the welcome and the code - worked a treat.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,779
Messages
6,126,843
Members
449,343
Latest member
DEWS2031

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