Excel allows you to open quite a few workbooks at the same time, depending on the amount of memory you have available on your system. For some people it is not unusual to have ten, fifteen, twenty, or more workbooks open, all at once.
Traditionally, the normal method used to switch from one workbook to another is to display the View tab of the ribbon and use the Switch Windows tool to select the desired workbook. If there are more than nine workbooks open and you click the Switch Windows tool, Excel displays an option that says “More Windows.” Click the option and you can see a display of all open workbooks. Selecting a workbook from this list ends up in that workbook being displayed.
If you routinely work with many open workbooks, it can be a pain to repeatedly click the Switch Windows tool, click More Windows, and then select which workbook you want to view. It would be much easier if the workbooks were all listed and if you could then select from the list. Unfortunately, Excel doesn’t allow you to display more than nine workbooks using the Switch Windows tool. (Nine seems to be a rather arbitrary number, but Microsoft had to set a limit somewhere. Nine is just as good as any other arbitrary limit.) There are, however, some workarounds you can use.
The first workaround is to use the task-switching capabilities of Excel. Just hold down the Alt key as you repeatedly press the Tab key to switch from one window to another. When the desired workbook window is selected, release the Alt key and the actual workbook is displayed.
You can also develop macros to display a list of workbooks, allow you to select one, and then switch among them. The most efficient way to do this is to create a UserForm and attach several macros to it. Follow these steps:
- Make sure you have created a Personal workbook to contain your common macros. (How this is done has been discussed in other issues of ExcelTips.)
- Press Alt+F11 to display the VBA Editor.
- Make sure the Personal workbook is selected in the Project window. (Upper-left corner of the VBA Editor.)
- Choose UserForm from the Insert menu. A new UserForm appears in the center of your screen.
- Using the toolbox at the left side of the VBA Editor, place a ListBox control on the UserForm. This control will hold the list of open workbooks. (Feel free to make the ListBox as large or small as desired.)
- Add any other items desired to the UserForm, such as explanation text, etc.
- Resize the UserForm to the size you want displayed.
- Right-click on the UserForm (not on the ListBox) and select View Code from the Context menu. You then see the Code window for the UserForm.
- Replace whatever is in the Code window with the following code:
- Choose Module from the Insert menu. A Code window appears for the new module.
- Add the following code to the module’s Code window:
- Close the VBA Editor and return to Excel by pressing Alt+Q.
Private Sub ListBox1_Click() Windows(ListBox1.Value).Activate Unload Me End Sub Private Sub UserForm_Activate() Dim wkb As Workbook For Each wkb In Workbooks If Windows(wkb.Name).Visible Then _ ListBox1.AddItem wkb.Name Next End Sub
Sub AllWindows() UserForm1.Show End Sub
Once in Excel, you can assign the AllWindows macro to the Quick Access Toolbar or to a shortcut key. When you then click on the toolbar button or the shortcut key, the UserForm is displayed, showing all the open workbooks. You can then select one, and the UserForm disappears and the selected workbook is displayed.