Macro Mondays -Open An Excel Workbook To A Specific Worksheet Tab


Hello Excellers, welcome to another blog post in my #MacroMonday series. Most Excel workbooks contain more than one worksheet, which can be helpful when you want to keep related data together. However, sometimes, you may only want to view data from a specific worksheet tab within a workbook. This blog post will show you how to open an Excel workbook to a particular worksheet tab. So, this tiny bit of VBA code will ALWAYS open at a specific worksheet or tab no matter what worksheet was active when the workbook was last closed and saved. If you want to see all of the blog posts in the Macro Mondays Series, you can click on the link below.

How To Excel At Excel – Macro Mondays Blog Posts.

Excel Macro

Step 1. Prepare To Write The Macro.

First, we will need to open the Visual Basic Editor. There are two ways to do this. Either by hitting ALT +F11 or selecting the Developer Tab | Code Group | Visual Basic. Both methods have the same result.

Once in the Visual Basic Editor, it is time to write the code. Now, as this code is particular to this workbook, it needs to be saved in the workbook—no need to create a module as it uses the Workbook_Open method, that open the workbook to specific tab.

Step 2. Use The Workbook_Open Event.

Next, in the project window find the workbook name. Do this by clicking the + sign and to see all of the worksheets. Click ThisWorkbook and select the Open event in the Event drop down list. Excel will automatically insert the following lines of code for you. Any other lines of code sit in between these two lines.

Private Sub Workbook_Open()

End Sub

Step 3. Write The Two Lines Of Code To Open The Workbook To A Specific Tab.

There is really one simple step in this Macro. to name the sheet tab you want Excel to open the workbook to. In my example I have chosen “MM22”. Finally, time to test your code.

open workbook to specific tab
Learn Excel Dashboard Course

Barbara

Barbara is an experienced data analyst with over 20 years of experience. Author of the How To Excel At Excel Top 50 Excel tips Ebook, YouTuber and Excel Blogger.

Recent Posts