View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Listbox for navigation

Max,

Here's one way. Create a toolbar with the listbox on. This code assumes that
on Sheet3, column A has the Ids, column B has the worksheet names. Select
from the listbox, and that sheet is activated.

Private Sub Workbook_Open()
Dim i As Long

On Error Resume Next
Application.CommandBars("File List").Delete
On Error GoTo 0
With Application.CommandBars.Add(Name:=("File List"), _
temporary:=True)
.Controls.Add(Type:=msoControlDropdown).Caption = _
"DD Test"
With .Controls("DD Test")
.BeginGroup = True
For i = 1 To Worksheets("Sheet3").Cells(Rows.Count,
"A").End(xlUp).Row
.AddItem Worksheets("Sheet3").Cells(i, "A")
Next i
.OnAction = "ThisWorkbook.myMacro"
.ListIndex = 1
End With
.Visible = True
End With
End Sub

Sub myMacro()
With Application.CommandBars("File List").Controls("DD Test")
Worksheets(Worksheets("Sheet3").Cells(.ListIndex,
"B").Value).Activate
End With
End Sub


It goes in the ThisWorkbook code module.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"MaxRott" wrote in message
...
Ok, I have not been using excel or programmed VB in a while. I am trying
to create a workbook that will have about 40 items on one sheet
(sheet1), I want these items to be displayed in a list box on another
sheet (sheet2). Now for the tricky part, each of the 40 items will have
a sheet of data corresponding to it. I would like to create a method in
which the selection in the listbox will display the corresponding
sheet. Maybe keep a list box on every sheet of data so that I can
navigate freely between all 40 sheets based on my selection. Anyone
have any ideas? Any help is much appreciated.


---
Message posted from http://www.ExcelForum.com/