Learn

Macro 6: Open a Workbook to a Specific Tab

Macro 6: Open a Workbook to a Specific Tab

In some situations, it’s imperative that your workbook be started on a specific worksheet. With this

macro, if a user is working with your workbook, they can’t go astray because the workbook starts on

the exact worksheet it needs to.

How it works

This macro uses the workbook’s Open event to start the workbook on the specified sheet when the

workbook is opened.

Private Sub Workbook_Open()

‘Step 1: Select the specified sheet

Sheets(“Sheet1”).Select

End Sub

The macro explicitly names the sheet the workbook should jump to when it’s opened.

How to use it

To implement this macro, you need to copy and paste it into the Workbook_Open event code win-

dow. Placing the macro here allows it to run each time the workbook opens.

1. Activate the Visual Basic Editor by pressing ALT+F11 on your keyboard.

2. In the Project window, find your project/workbook name and click the plus sign next to it in

order to see all the sheets.

3. Click ThisWorkbook.

4. Select the Open event in the Event drop-down list (see Figure 2-6).

5. Type or paste the code in the newly created module, changing the sheet name, if necessary.

Figure 2-6: Type or paste your code in the Workbook_Open event code window.

learn
We will be happy to hear your thoughts

Leave a reply

Share knowledge
Learn
Logo
Enable registration in settings - general