Excel 2007 Switch Windows

joefrench

Active Member
Joined
Oct 4, 2006
Messages
357
Over the past year, I've found that switching between multiple workbooks and performing different operations can be a bit cumbersome in Excel 2007 with the Ribbon (they've added a few user clicks just to switch windows).
While assisting a member of the board(in this thread), I realized that what we were working on would help resolve this slight nuisance. So I turned it into an AddIn and added the macro to my Quick Access Toolbar. :biggrin: All that it requires is a UserForm with two ListBoxes.

I'm sure that I am not the first to do this but I figured I'd post it here in case there are one or two other users that would like something like this!

Here's the code:
UserForm Module
Code:
Private Sub ListBox1_Click()
Dim actvWb, wsName As String
Dim ws As Worksheet
    For i = 0 To Me.ListBox1.ListCount - 1
        If Me.ListBox1.Selected(i) Then
            actvWb = Me.ListBox1.List(Me.ListBox1.ListIndex, 0)
        End If
    Next i
    
Application.Workbooks(actvWb).Activate

Me.ListBox2.Clear
With Me.ListBox2
    For Each ws In Application.Workbooks(actvWb).Worksheets
        wsName = ws.Name
        .AddItem wsName
    Next
End With

End Sub
'***********************************
Private Sub ListBox2_Click()
Dim actvWs As String
Dim ws As Worksheet
    For i = 0 To Me.ListBox2.ListCount - 1
        If Me.ListBox2.Selected(i) Then
            actvWs = Me.ListBox2.List(Me.ListBox2.ListIndex, 0)
        End If
    Next i
    
Sheets(actvWs).Activate
Unload Me
End Sub
'***********************************
Private Sub UserForm_Initialize()
Dim wbName As String
Dim wb As Object
Dim listQty As Integer
Dim rStart As Range
Set rStart = Sheet1.Range("A:A")

With Me.ListBox1
    For Each wb In Application.Workbooks
        wbName = wb.Name
        .AddItem wbName
    Next
End With
End Sub

Probably not the best coding but it was whipped together pretty quickly and is functional (for me anyway).

Cheers!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,225,360
Messages
6,184,508
Members
453,237
Latest member
lordleo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top