Thread
:
Custom CommandBar visible dependent on active sheet
View Single Post
#
2
Posted to microsoft.public.excel.programming
Nigel[_2_]
external usenet poster
Posts: 735
Custom CommandBar visible dependent on active sheet
You will need a Worksheet_Activate event code on each sheet. Since the
code is similar I suggest you create a sub to handle all toolbars and pass
the Active sheet to this sub.
So on each sheet A,B,C etc. (code behind each sheet)
Private Sub Worksheet_Activate
myToolBars ActiveSheet
End Sub
Then in standard module
Sub myToolBars (wS as Worksheet)
CommandBars("SheetA").Visible = False
CommandBars("SheetB").Visible = False
CommandBars("SheetC").Visible = False
Select Case wS.Name
Case Is = "SheetA": CommandBars("SheetA").Visible = True
Case Is = "SheetB": CommandBars("SheetB").Visible = True
Case Is = "SheetC": CommandBars("SheetC").Visible = True
End Select
End Sub
--
Regards,
Nigel
"cagey63" wrote in message
...
Similar to an earlier post (noted below), I've created custom command
bars with associated macros pertaining to the data on a specific Excel
sheet. In other words, I want to see only the toolbar containing the
commands pertaining to the sheet when a sheet is selected. Here is
the code I've tried:
Private Sub Worksheet_Activate()
If ActiveSheet.Name = ("SheetA") Then
.CommandBars("SheetA").Visible = True
Else
.CommandBars("SheetA").Visible = False
End If
If ActiveSheet.Name = ("SheetB") Then
.CommandBars("SheetB").Visible = True
Else
.CommandBars("SheetB").Visible = False
End If
If ActiveSheet.Name = ("SheetC") Then
.CommandBars("SheetC").Visible = True
Else
.CommandBars("SheetC").Visible = False
End If
End Sub
Note that I already have code for enabling the toolbars on workbook
activation functioning.
Thanks.
Previous post:
http://groups.google.com/group/micro...ef929af02d7be1
Reply With Quote
Nigel[_2_]
View Public Profile
Find all posts by Nigel[_2_]