This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Workbook.ActiveSheet property (Excel)

  • 6 contributors

Returns a Worksheet object that represents the active sheet (the sheet on top) in the active workbook or specified workbook. Returns Nothing if no sheet is active.

expression . ActiveSheet

expression A variable that represents a Workbook object.

Using the ActiveSheet property without an object qualifier returns the active sheet in the active workbook in the active window.

If a workbook appears in more than one window, the active sheet might be different in different windows.

This example displays the name of the active sheet.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Was this page helpful?

Submit and view feedback for

Additional resources

How to Activate a Sheet using VBA

Let’s say you are working with multiple worksheets, and for you, it’s hard to navigate to a sheet using a tab. In this situation, you can use a VBA code to activate any worksheet.

And, to write a VBA code for this you need to use Worksheet.Activate Method. In this post, I’d like to share with you a simple way to write this code to activate or select a worksheet. Before you write this code, you need to understand this method.

Worksheet.Activate Method

In this method, you can specify the worksheet’s name or number which you want to activate. Let’s say you need to activate sheet1, then the code will be:

Or you can use sheet numbers as well.

So the final code will be:

Examples: Activate a Worksheet with VBA

In the real life, you can use this method in different ways. Here are some of them.

1. Activate a Worksheet on Opening

If you want to activate a specific worksheet every time when you open the workbook then you name that VBA code auto_open.

2. Activate a Worksheet and Hide all other

Maybe you want to navigate to a worksheet and hide all the other worksheets from the workbook. You can do this by using the below code.

Change the sheet name from the above code to use it further.

Related Tutorials

  • CLEAR an Entire Sheet using VBA in Excel
  • Copy and Move a Sheet in Excel using VBA
  • COUNT Sheets using VBA in Excel
  • DELETE a SHEET using VBA in Excel
  • Hide & Unhide a Sheet using VBA in Excel
  • PROTECT and UNPROTECT a Sheet using VBA in Excel
  • RENAME a Sheet using VBA in Excel
  • Write a VBA Code to Create a New Sheet in Excel
  • VBA Worksheet Object
  • VBA Check IF a Sheet Exists

10 thoughts on “How to Activate a Sheet using VBA”

Hi there , I am below average user of excel and a programmer of Harbour and want to add some formatting to excel sheet can you guide about or a help file to get it , Like merge of cells changing backgroud (fill) color of cell, I am able to change text colour etc. Thanks

My favourite excel help site of late – no faff! Nice job, thank you kindly

I’m doing a class lab inventory. I created a macros that one click it can show the database available. But I want to hide this data.xlsx. from borrower. But if i manually hide the data.xlsx , the macros can’t work. So could you advice on this matter.

Sub changeSh() ‘Application.ScreenUpdating = True its true by default

Dim wkb As Workbook Set wkb = ThisWorkbook

wkb.Sheets(“Data”).Activate

Sub changeSh() Dim wkb As Workbook Set wkb = ThisWorkbook wkb.Sheets(“Data”).Activate End Sub

Ajay, I would first ask why password protect multiple workbooks? Should these not be protected individually? There are several ways in which a workbook can be protected. Would you be protecting them from being edited? If so, can others see a read only version or not? I think you can see your question has not been developed fully.

Ali, the answer to you question would be to set up a keyboard shortcut. You would need to assign a different shortcut to each worksheet. I would keep it simple. Using the example above I would use Shift+Ctrl+A. Then, for worksheet 2 I would use Shift+Ctrl+B.

Is there any vba code to encrypt multiple workbooks I. E. Lock multiple workbooks at a time

Sorry, didn’t Understand Entirely. Guess, I have 16 worksheets in a workbook. Want to go sheet number 8 (say Sheet 8). After working in that sheet, want to go sheet number 2 (say Sheet 2). Then how use this tricks?

Thanks in advance.

very interesting

Can you publish a sample file with above VBA codes.

Leave a Comment Cancel reply

IMAGES

  1. VBA Activate Sheet

    how to make worksheet active vba

  2. VBA Worksheet Function

    how to make worksheet active vba

  3. Excel Vba Add Worksheet After Activesheet

    how to make worksheet active vba

  4. Count Sheets

    how to make worksheet active vba

  5. Vba Worksheets Activate

    how to make worksheet active vba

  6. Vba Set Active Workbook And Worksheet For Kids

    how to make worksheet active vba

VIDEO

  1. Excel VBA

  2. how to make worksheet of science on html? #shorts #computer

  3. Details VBA Code for Highlight Active Cell in Excel Sheet

  4. A must know Excel VBA Code 👨‍💻

  5. VBA in Excel

  6. VBA Macro Excel

COMMENTS

  1. VBA ActiveSheet & How To Activate or Select a Sheet

    Only one Sheet may be active at a time. Activate Worksheet (Setting the ActiveSheet) To set the ActiveSheet use Worksheet.Activate: Worksheets ("Input").Activate The Activate Sheet command will actually “go to” the sheet, changing the visible Sheet. The above example uses the Sheet (Tab) name.

  2. Worksheet.Activate method (Excel)

    Makes the current sheet the active sheet. Syntax. expression.Activate. expression A variable that represents a Worksheet object. Remarks. Calling this method is equivalent to choosing the sheet's tab. Example. This example activates Sheet1. Worksheets("Sheet1").Activate Support and feedback. Have questions or feedback about Office VBA or this ...

  3. Workbook.ActiveSheet property (Excel)

    Using the ActiveSheet property without an object qualifier returns the active sheet in the active workbook in the active window. If a workbook appears in more than one window, the active sheet might be different in different windows. Example. This example displays the name of the active sheet. MsgBox "The name of the active sheet is ...

  4. How to Activate a Sheet using VBA

    1. Activate a Worksheet on Opening If you want to activate a specific worksheet every time when you open the workbook then you name that VBA code auto_open. Sub auto_open() Worksheets("Sheet1").Activate End Su 2. Activate a Worksheet and Hide all other Maybe you want to navigate to a worksheet and hide all the other worksheets from the workbook.