In this Article
This tutorial will demonstrate how to activate a workbook using VBA.
Activate with Object Name
The most obvious way to activate a workbook is by referencing its name in the Workbooks Object.
Activate with Workbook Number
However, you can also activate workbooks by referring to their “number”. The workbook number is determined by the order in which the workbooks were opened.
So workbook 1 is the first opened workbook, workbook 2 is the second, etc.
The ThisWorkbook Object is the workbook where the running code is stored. To activate ThisWorkbook use this line of code:
Once a workbook has been activated, it becomes the ActiveWorkbook. To see the ActiveWorkbook you can use this line of code to fetch the ActiveWorkbook name:
VBA Coding Made EasyStop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!