Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I am trying to write some code which would construct a menu item of all the sheets in the workbook. I am new to VBA and I know it will take me hours. Has anyone done something like this before? Even better, does anyone know how to increase the number of sheets shown when you left click on the arrow buttons at the left of the sheet tabs? Des -- DesM ------------------------------------------------------------------------ DesM's Profile: http://www.excelforum.com/member.php...o&userid=24121 View this thread: http://www.excelforum.com/showthread...hreadid=480871 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This may help you:
Sub ShowSheetList() On Error Resume Next Err = 0 'Try to show dialog for 15 sheet workbooks CommandBars("Workbook Tabs").Controls("More sheets...").Execute 'If an error there are fewer than 16 sheets so show the "short list" If Err < 0 Then CommandBars("Workbook Tabs").ShowPopup End Sub -- Jim "DesM" wrote in message ... | | I am trying to write some code which would construct a menu item of all | the sheets in the workbook. I am new to VBA and I know it will take me | hours. | Has anyone done something like this before? | Even better, does anyone know how to increase the number of sheets | shown when you left click on the arrow buttons at the left of the sheet | tabs? | Des | | | -- | DesM | ------------------------------------------------------------------------ | DesM's Profile: http://www.excelforum.com/member.php...o&userid=24121 | View this thread: http://www.excelforum.com/showthread...hreadid=480871 | |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Take a look at David McRitchie's BuildTOC:
http://www.mvps.org/dmcritchie/excel/buildtoc.htm In article , DesM wrote: I am trying to write some code which would construct a menu item of all the sheets in the workbook. I am new to VBA and I know it will take me hours. Has anyone done something like this before? Even better, does anyone know how to increase the number of sheets shown when you left click on the arrow buttons at the left of the sheet tabs? Des |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello DesM, Here is the code for a macro that adds a Drop Down List to Excel's Cel Popup Menu. The menu you see whenever you Right Click a cell on Worksheet. The macro updates the list whenever a new Worksheet is adde or deleted. Selecting a Worksheet from the Drop Down List brings that Worksheet t the top. You can switch Worksheets quickly and easily using this Popu control. Code ------------------- Public Sub AddWorksheetList() 'This macro installs the Drop Down List control on the Cell Popup Menu Dim cbCell As CommandBar Dim ctlDropDown As CommandBarControl Dim Wks On Error Resume Next Excel.CommandBars("Cell").Controls("Go To Worksheet").Delete Err = 0 Set cbCell = Excel.CommandBars("Cell") Set ctlDropDown = cbCell.Controls.Add(msoControlDropdown) For Each Wks In ThisWorkbook.Worksheets ctlDropDown.AddItem Wks.Name Next Wks With ctlDropDown .Caption = "Go To Worksheet" .OnAction = "GoToWorksheet" .BeginGroup = True End With End Sub Sub GoToWorksheet() 'This macro Activate the selected Worksheet and updates the list Dim cbCtl As CommandBarControl Dim Wks Set cbCtl = Excel.CommandBars("Cell").Controls("Go To Worksheet") If ThisWorkbook.Worksheets.Count < cbCtl.ListCount Then cbCtl.Clear For Each Wks In ThisWorkbook.Worksheets cbCtl.AddItem Wks.Name Next Wks MsgBox "Worksheet List has been Updated" & vbCrLf & "Please Re-select a Worksheet" Exit Sub End If Wks = cbCtl.Text If Wks < "" Then ThisWorkbook.Worksheets(Wks).Activate End If End Sub ------------------- INSTALLING THE MACROS -Copying the Macros... - 1) Go to the Code Window above and Scroll to the Top of the code. 2) Place the mouse pointer to the Left of the First Lne. 3) Left Click and Hold the Mouse Button Down. 4) Move the mouse to Last Line of code and Release the Left Mous Button. 5) The Code should all be highlighted. 6) Press and Hold the *CTRL* key and then press the *C* key. Thi copies the code. -Inserting a Project Module... - 1) With an Excel Workbook Open, press and hold the *ALT* key and the the *F11* Key. This starts the VBA Editor. 2) Press and hold the *ALT* key and then the *I* key. This activate the Insert Menu. 3) Press the *M* key. This inserts a project module into you Workbook. 4) Press and hold the *CTRL* key and then press the *V* key. This wil paste the macro code into the module. 5) Press and hold the *CTRL* key and then press the *S* key. This wil Save the code. -Adding the Macro to the Popup Menu... - 1) Press and hold the *ALT* key and then press the *Q* key. This take you back to Excel. 2) Press and hold the *ALT* key and then press the *F8* key. Thi brings up the Macro list. 3) Find -AddWorksheetList-. 4) Move the mouse pointer to it and Left Click to select it. 5) Press the *Enter* key to Run the macro. This installs it. 6) Press and hold the *CTRL* key and then press the *S* key. This Save the menu change. That all there is to it. You're done. Sincerely, Leith Ros -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() to: Leith Ross Thanks indeed for this. Is it possible to expand the size of the pulldown window to avoi having to scroll? Regards, Des Murph -- Des ----------------------------------------------------------------------- DesM's Profile: http://www.excelforum.com/member.php...fo&userid=2412 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello DesM, There maybe a way to increase the size, but I haven't discovered i yet. Sincerely, Leith Ris -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello DesM, There maybe a way to increase the size, but I haven't discovered i yet. Sincerely, Leith Ros -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() To:Leith Ross Sorry, but I've made a mess. I ran the macro several times and now have many "Go to Workbook" pull down controls on my right clic window. Even when I close Excel and open a clean workbook they are there. Can I clear them? Des Murph -- Des ----------------------------------------------------------------------- DesM's Profile: http://www.excelforum.com/member.php...fo&userid=2412 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() to: Leith Ross Thanks indeed for this. Is it possible to expand the size of the pulldown window to avoi having to scroll? Regards, Des Murph -- Des ----------------------------------------------------------------------- DesM's Profile: http://www.excelforum.com/member.php...fo&userid=2412 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello DesM, Here is the code for a macro that adds a Drop Down List to Excel's Cel Popup Menu. The menu you see whenever you Right Click a cell on Worksheet. The macro updates the list whenever a new Worksheet is adde or deleted. Selecting a Worksheet from the Drop Down List brings that Worksheet t the top. You can switch Worksheets quickly and easily using this Popu control. Code ------------------- Public Sub AddWorksheetList() 'This macro installs the Drop Down List control on the Cell Popup Menu Dim cbCell As CommandBar Dim ctlDropDown As CommandBarControl Dim Wks On Error Resume Next Excel.CommandBars("Cell").Controls("Go To Worksheet").Delete Err = 0 Set cbCell = Excel.CommandBars("Cell") Set ctlDropDown = cbCell.Controls.Add(msoControlDropdown) For Each Wks In ThisWorkbook.Worksheets ctlDropDown.AddItem Wks.Name Next Wks With ctlDropDown .Caption = "Go To Worksheet" .OnAction = "GoToWorksheet" .BeginGroup = True End With End Sub Sub GoToWorksheet() 'This macro Activate the selected Worksheet and updates the list Dim cbCtl As CommandBarControl Dim Wks Set cbCtl = Excel.CommandBars("Cell").Controls("Go To Worksheet") If ThisWorkbook.Worksheets.Count < cbCtl.ListCount Then cbCtl.Clear For Each Wks In ThisWorkbook.Worksheets cbCtl.AddItem Wks.Name Next Wks MsgBox "Worksheet List has been Updated" & vbCrLf & "Please Re-select a Worksheet" Exit Sub End If Wks = cbCtl.Text If Wks < "" Then ThisWorkbook.Worksheets(Wks).Activate End If End Sub ------------------- INSTALLING THE MACROS -Copying the Macros... - 1) Go to the Code Window above and Scroll to the Top of the code. 2) Place the mouse pointer to the Left of the First Lne. 3) Left Click and Hold the Mouse Button Down. 4) Move the mouse to Last Line of code and Release the Left Mous Button. 5) The Code should all be highlighted. 6) Press and Hold the *CTRL* key and then press the *C* key. Thi copies the code. -Inserting a Project Module... - 1) With an Excel Workbook Open, press and hold the *ALT* key and the the *F11* Key. This starts the VBA Editor. 2) Press and hold the *ALT* key and then the *I* key. This activate the Insert Menu. 3) Press the *M* key. This inserts a project module into you Workbook. 4) Press and hold the *CTRL* key and then press the *V* key. This wil paste the macro code into the module. 5) Press and hold the *CTRL* key and then press the *S* key. This wil Save the code. -Adding the Macro to the Popup Menu... - 1) Press and hold the *ALT* key and then press the *Q* key. This take you back to Excel. 2) Press and hold the *ALT* key and then press the *F8* key. Thi brings up the Macro list. 3) Find -AddWorksheetList-. 4) Move the mouse pointer to it and Left Click to select it. 5) Press the *Enter* key to Run the macro. This installs it. 6) Press and hold the *CTRL* key and then press the *S* key. This Save the menu change. That all there is to it. You're done. Sincerely, Leith Ros -- Leith Ros ----------------------------------------------------------------------- Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846 View this thread: http://www.excelforum.com/showthread.php?threadid=48087 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to create menu for listed names? | Excel Worksheet Functions | |||
How to create menu for listed names? | Excel Discussion (Misc queries) | |||
Newbie-need menu of names | Excel Programming | |||
drop down menu containing worksheet names | Excel Worksheet Functions | |||
return all worksheet tab names and chart sheet tab names in report - an example | Excel Programming |