Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

CommandButton code help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
peter.thompson - 22 Jan 2006 20:54 GMT
I want to use a common set of 7 commandbuttons as a 'menu bar' on
several worksheets (each commandbutton opens a worksheet instead of
using the standard tabs)

What is the best way to go about this to minimise code?

Any help much appreciated

Cheers

Peter

Signature

peter.thompson

Bob Phillips - 22 Jan 2006 23:39 GMT
Peter,

I add a drop-down to the Formatting toolbar, and in ThisWorkbook, I setup up
the toolbar buton and populate it so

Private Workbook_Open()
   With Application.CommandBars("Formatting")
       With .Controls.Add(Type:=msoControlDropdown, temporary:=True)
           .Caption = "SheetGoto"
           .OnAction = "GotoSheet"
       End With    End With
End Sub

Private Sub Workbook_Activate()
Dim i As Long

   With Application.CommandBars("Formatting").Controls("SheetGoto")
       .Clear
       For i = 1 To Wb.Sheets.Count
           .AddItem Wb.Sheets(i).Name
       Next i
       .ListIndex = 1
   End With
End Sub

In a standard code module I add this macro to actiavte the sheet

Private Sub GotoSheet()
   With Application.CommandBars.ActionControl
       ActiveWorkbook.Sheets(.Text).Activate
   End With
End Sub

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

> I want to use a common set of 7 commandbuttons as a 'menu bar' on
> several worksheets (each commandbutton opens a worksheet instead of
[quoted text clipped - 13 lines]
> peter.thompson's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29686
> View this thread: http://www.excelforum.com/showthread.php?threadid=503840
Tom Ogilvy - 22 Jan 2006 23:47 GMT
Use commandbar buttons instead.

otherwise, used the technique shown here at John Walkenbach's site:
http://www.j-walk.com/ss/excel/tips/tip44.htm

Signature

Regards,
Tom Ogilvy

> I want to use a common set of 7 commandbuttons as a 'menu bar' on
> several worksheets (each commandbutton opens a worksheet instead of
[quoted text clipped - 7 lines]
>
> Peter
peter.thompson - 23 Jan 2006 01:32 GMT
Thanks guys, much appreciated.

Cheers

Peter

Signature

peter.thompson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.