How to activate a specific worksheet in Excel Using VBA

Activate Workbook or Worksheet

If you know the name of the workbook You can use the following code to Activate Workbook or worksheet. For example workbook name is “Book2” which we want to activate and it contains sheet named as “Sheet1”. Using following code you can Activate Workbook Or Work Sheet.

 

 

VBA Activate Worksheet – with Name: Example 1

 

Please see the below VBA codes to activate Worksheet. In this example we are activating a Worksheet named “Project1”.

Sub Activate_Sheet()


    Worksheets("Sheet1").Activate
    'Or
    Sheets("Sheet2").Activate


End Sub


VBA Activate Worksheet Method– with Number: Example 2

Please see the below VBA code or macro procedure to activate Worksheet. In this example we are activating first Worksheet in the active workbook.

Sub Activate_Sheet_BasedOnIndex()

    Worksheets(1).Activate
    'Or
    Sheets(1).Activate

End Sub


 

 

Code:

 

Sub Activate_Workbook()

    
    'Activate Workbook
    Workbooks("Book2.xls").Activate   

    'Activate Worksheet
    Workbooks("Book2.xls").Sheets("Sheet1").Activate


End Sub


 

Would the following Macro help you?

Share This Post

1,380 comments