Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandButton code help


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


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=503840

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default CommandButton code help

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("Sh eetGoto")
.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)

"peter.thompson"
wrote in
message news:peter.thompson.2220hm_1137963301.313@excelfor um-nospam.com...

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


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile:

http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=503840



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default CommandButton code help

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

--
Regards,
Tom Ogilvy

"peter.thompson"
wrote in
message news:peter.thompson.2220hm_1137963301.313@excelfor um-nospam.com...

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


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile:

http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=503840



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default CommandButton code help


Thanks guys, much appreciated.

Cheers

Peter


--
peter.thompson
------------------------------------------------------------------------
peter.thompson's Profile: http://www.excelforum.com/member.php...o&userid=29686
View this thread: http://www.excelforum.com/showthread...hreadid=503840

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
? activate a commandbutton in code ? tad_wegner[_6_] Excel Programming 1 October 10th 05 04:43 PM
CommandButton Code oberon.black[_58_] Excel Programming 3 September 16th 05 04:59 PM
Can You Change A CommandButton Code Using A Macro? Donna[_7_] Excel Programming 4 February 11th 05 08:38 AM
CommandButton Alvin Hansen[_2_] Excel Programming 3 August 16th 04 06:35 PM
Code runs different in a commandbutton than a macro why? Neal Miller Excel Programming 7 December 7th 03 02:41 AM


All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"