JonRowland
Active Member
- Joined
- May 9, 2003
- Messages
- 417
- Office Version
- 365
- Platform
- Windows
Hi,
I looking to create a toolbar menu which will contain names of worksheets within my spreadsheet allow a quick naviagation, ie select the sheet name you want and you get taken there. The menu will ignore certain defined worksheet names.
So for example I have 4 worksheets. I want to ignore the sheet called IGNORE and the others (eg 4Menu1, 4Menu2, 4Menu3) I want to be included in a new menu called SheetM. As I add worksheets I would like to recreate the menu so it includes my new ones.
I've got so far but not sure how I can capture the sheetnames and get then as a caption within the menu and then to navigate to that sheet when selected.
This is what I've come up with so far. Can anyone help? This is aimed at XL97 as well as 2007.
Sub Sheet_Menu()
Dim SheetMenuSubItem As Object
Dim VLastusedrow As Long
Dim wSht As Worksheet
Dim allwShts As Sheets
Set allwShts = Worksheets
CommandBars("Worksheet menu bar").Controls.Add(Type:=msoControlPopup).Caption = "SheetM"
For Each wSht In allwShts
If wSht.Name <> "IGNORE" Then wSht.Activate
End If
Next
Set SheetMenuSubItem = CommandBars("worksheet menu bar").Controls("SheetM")
With SheetMenuSubItem
.Controls.Add(Type:=msoControlButton).Caption = "SHEET NAME HERE"
.Controls("Add New DataSheet").OnAction = "TAKE ME TO THE SHEET"
End With
End Sub
Thanks
Jon
I looking to create a toolbar menu which will contain names of worksheets within my spreadsheet allow a quick naviagation, ie select the sheet name you want and you get taken there. The menu will ignore certain defined worksheet names.
So for example I have 4 worksheets. I want to ignore the sheet called IGNORE and the others (eg 4Menu1, 4Menu2, 4Menu3) I want to be included in a new menu called SheetM. As I add worksheets I would like to recreate the menu so it includes my new ones.
I've got so far but not sure how I can capture the sheetnames and get then as a caption within the menu and then to navigate to that sheet when selected.
This is what I've come up with so far. Can anyone help? This is aimed at XL97 as well as 2007.
Sub Sheet_Menu()
Dim SheetMenuSubItem As Object
Dim VLastusedrow As Long
Dim wSht As Worksheet
Dim allwShts As Sheets
Set allwShts = Worksheets
CommandBars("Worksheet menu bar").Controls.Add(Type:=msoControlPopup).Caption = "SheetM"
For Each wSht In allwShts
If wSht.Name <> "IGNORE" Then wSht.Activate
End If
Next
Set SheetMenuSubItem = CommandBars("worksheet menu bar").Controls("SheetM")
With SheetMenuSubItem
.Controls.Add(Type:=msoControlButton).Caption = "SHEET NAME HERE"
.Controls("Add New DataSheet").OnAction = "TAKE ME TO THE SHEET"
End With
End Sub
Thanks
Jon