Toolbar to launch Macros

F

Fan924

I have created a customized Toolbar to launch Macros , a procedure by
Dave Peterson. Adds a nice professional touch.
http://www.contextures.com/xlToolbar02.html#Setup
I need to limit the macro only to a few sheets. Can I add code to
"Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)"
that will enable or disable my toolbar macro?
 
C

CurlyDave

Try the workbook module instead

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
If ActiveSheet.Name = "Sheet1" Or ActiveSheet.Name = "Sheet2" Then
MsgBox "Your toolBar Macro Here" 'change to Call CreateMenubar
End If
End Sub

Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
MsgBox "Your remove toolbar Macro Here" ' change to Call RemoveMenubar
End Sub
 
G

Gary Keramidas

I'll just use something like this in the sheet code mdules:

Private Sub Worksheet_Deactivate()
RemoveToolbar ' this is contains code that removes the toolbar
End Sub

and

Private Sub Worksheet_Deactivate()
CreateToolbar ' this module contains code to create the toolbar
End Sub
 
F

Fan924

Thanks guys. I guess i didn't study it long enough. The downloaded
from the link above contained the following.
Sub RemoveMenubar()
Sub CreateMenubar()
Now it turns on and off when I select a sheet. Looking good.

The toolbar pops up in the middle of the page and not with the other
menus at the top.
Any way to fix that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top