Thanks
Linda
Put your cursor down in the tab area -- all way to left and right click
Select sheet
"Linda" <Romula...@StarfleetHeadquarters.xp> wrote in message
news:%23C3cN1B...@TK2MSFTNGP11.phx.gbl...
: Since you were so quick and helpful about my index question......... If I
:
:
Linda
"Lady Layla" <Ladyla...@yahoo.com> wrote in message
news:O8gkVZCj...@TK2MSFTNGP11.phx.gbl...
Thanks,
Linda
"Otto Moehrbach" <ottom...@att.net> wrote in message
news:#DbJkFFj...@tk2msftngp13.phx.gbl...
The default behavior when you type into the combobox on that toolbar is to match
the entries.
Option Explicit
Sub auto_close()
On Error Resume Next
Application.CommandBars("MyNavigator").Delete
On Error GoTo 0
End Sub
Sub auto_open()
Dim cb As CommandBar
Dim ctrl As CommandBarControl
Dim wks As Worksheet
On Error Resume Next
Application.CommandBars("MyNavigator").Delete
On Error GoTo 0
Set cb = Application.CommandBars.Add(Name:="myNavigator", temporary:=True)
With cb
.Visible = True
Set ctrl = .Controls.Add(Type:=msoControlButton, temporary:=True)
With ctrl
.Style = msoButtonCaption
.Caption = "Refresh Worksheet List"
.OnAction = ThisWorkbook.Name & "!refreshthesheets"
End With
Set ctrl = .Controls.Add(Type:=msoControlComboBox, temporary:=True)
With ctrl
.AddItem "Click Refresh First"
.OnAction = ThisWorkbook.Name & "!changethesheet"
.Tag = "__wksnames__"
End With
End With
End Sub
Sub ChangeTheSheet()
Dim myWksName As String
Dim wks As Worksheet
With Application.CommandBars.ActionControl
If .ListIndex = 0 Then
MsgBox "Please select an existing sheet"
Exit Sub
Else
myWksName = .List(.ListIndex)
End If
End With
Set wks = Nothing
On Error Resume Next
Set wks = Worksheets(myWksName)
On Error GoTo 0
If wks Is Nothing Then
Call refreshthesheets
MsgBox "Please try again"
Else
wks.Select
End If
End Sub
Sub refreshthesheets()
Dim ctrl As CommandBarControl
Dim wks As Worksheet
Set ctrl = Application.CommandBars("myNavigator") _
.FindControl(Tag:="__wksnames__")
ctrl.Clear
For Each wks In ActiveWorkbook.Worksheets
ctrl.AddItem wks.Name
Next wks
End Sub
(If you swap workbooks, just click the other button to get a fresh list of
worksheet names in the dropdown.)
--
Dave Peterson
ec3...@msn.com
Linda
"Dave Peterson" <ec3...@msn.com> wrote in message
news:3F81FC25...@msn.com...
Try it on a test workbook with some nicely named worksheets.
When you're in excel,
hit alt-F11 (to get to the VBE)
then hit ctrl-R to see the project explorer (like windows explorer)
rightclick on your workbook/project (VBAProject (book1.xls))
select Insert, then Module
then paste that whole conglomeration in.
then back to excel and hit alt-F8 and doubleclick on Auto_open.
(auto_open will run when ever you open the workbook--so this time it's just for
testing)
Try it out.
It might be overkill, but once you set it up, you're done.
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
--
Dave Peterson
ec3...@msn.com
It says Macros in "This Workbook"
I don't see a floating tool bar though.
Linda
"Linda" <Romula...@IBMThinkPad.UFP> wrote in message
news:#FO2XSGj...@TK2MSFTNGP09.phx.gbl...
(Or close your workbook (save it, too). then reopen. xl will run the auto_open
macro whenever you open the workbook. and the auto_open code actually builds
the toolbar.)
--
Dave Peterson
ec3...@msn.com
Thanks,
Linda
"Dave Peterson" <ec3...@msn.com> wrote in message
news:3F820571...@msn.com...