vba how not to use activate

by Bennie Stanton MD 4 min read

Should I use select or activate in my Excel code?

Learn excel-vba - Avoid using SELECT or ACTIVATE. Example. It is very rare that you'll ever want to use Select or Activate in your code, but some Excel methods do require a worksheet or workbook to be activated before they'll work as expected.. If you're just starting to learn VBA, you'll often be suggested to record your actions using the macro recorder, then go look at the code.

What are some examples of activate a worksheet with VBA?

Feb 09, 2017 · Very new to Excel VBA here... Very similar to this post: Avoiding the use of Activate and Select when working with charts (Excel), I am attempting to avoid using Activate in order to make a small change to a number of Charts in a large workbook. I am performing this task for a good number of charts, so I would like to minimize the run-time as ...

What happens if I ignore the activeworkbook object in VBA?

Oct 13, 2016 · Select and Activate are basically just methods that are used in recording macros. To trim down a macro from there, you can do the following: Anywhere ActiveCell is used, simply replace it with the Range reference that .Activate was called on. (In your case, the first With ActiveCell.Font would become With Sheets("A4").Cells(1 + PageRowOffset(Page) + …

How to activate a range in Excel using VBA?

Jul 27, 2019 · Excel VBA Activate Sheet. For activating or selecting a sheet in excel, we manually go to the sheet and click on the Sheet tab. But when we write a code where we need to link the different sheets in different forms, then we can use the VBA Activate Sheet function. This can be done with the help of the “.Activate” command in VBA. This will automatically select or activate …


How do I stop VBA activation?

Probably the biggest thing you can do to avoid using Select is to as much as possible, use named ranges (combined with meaningful variable names) in your VBA code.

How do you avoid selection in Excel VBA?

0:0910:21Excel VBA Range - Avoid Select, You will be glad you did - YouTubeYouTubeStart of suggested clipEnd of suggested clipThe cardinal rule is don't you select in Excel VBA.MoreThe cardinal rule is don't you select in Excel VBA.

Can you select a worksheet without activating it?

3 Answers. If a worksheet is not the active sheet, it cannot have a selection nor an activecell. There is one Selection for the entire Excel application instance regardless of how many workbooks or worksheets or windows are open.Mar 31, 2018

What is the difference between activate and select in Excel VBA?

The short answer is that Select and Activate can perform the same action, but the differences are: Select can be used to select multiple objects (sheets, ranges, shapes, etc.) at the same time. Activate can be used to active one object within the selection.Jul 25, 2019

How do I not select anything in excel?

Sometimes when you're selecting multiple cells or ranges in Excel, you accidentally select one or more that you didn't intend. You can deselect any cells within the selected range with the Deselect Tool. Pressing the Ctrl key, you can click, or click-and-drag to deselect any cells or ranges within a selection.

How do you deselect a cell in VBA?

Normally, if you want to deselect a cell or multiple cells from a selection, you just need to hold down the CTRL key and click on the cells you want to deselect. If you want to unselect a range of selected cells, you need to hold down the CTRL key and drag the range you want to deselect.Dec 11, 2018

What does activate sheet do in VBA?

VBA Activate Worksheet method is used to makes the current sheet as active sheet.

What does Worksheet_Activate mean?

Worksheet_Activate event not fires Worksheet events do not fire when the workbook is opened. For example, the Worksheet_Activate() event for Sheet1 does not fired when the workbook is opened and Sheet1 is already activated. To check, you must select another sheet tab and select again that worksheet tab again.Mar 31, 2020

How do I change the active cell in VBA?

In VBA, the active cell is a property that represents the cell that is active at the moment....Use the Active Cell PropertyType the keyword “ActiveCell”.Type a dot (.) to get the list properties and methods.Select the property or method that you want to use.Run the code to perform the activity to the active cell.

What is range activate?

Activate (Excel) Activates a single cell, which must be inside the current selection. To select a range of cells, use the Select method. Worksheets("Sheet1").

What does activate mean in Excel?

Activate just simply makes the object the active object. Best way to think of it is "many cells can be selected, but only one may be the active cell at any given time."Aug 25, 2011

How do I activate a specific workbook in VBA?

Steps to Activate a WorkbookType “Workbooks” to use the workbook object.Specify the workbook name in the double quotation marks.Enter a dot (.) to get the list of properties and methods.Select the Activate method from the list or you can also type it.In the end, run the code to activate the workbook.

How to Activate Sheet in Excel VBA?

Below are the different examples to activate sheet in excel using VBA code.

Things to Remember

Select and Activate function has the same work of activating any worksheet. Although the name is different.

Recommended Articles

This is a guide to VBA Activate Sheet. Here we discussed how to Activate sheet in Excel using VBA code along with some practical examples and downloadable excel template. You can also go through our other suggested articles –


The object placeholder represents an object expression that evaluates to an object in the Applies To list.


The following code uses two UserForms: UserForm1 and UserForm2. Copy these procedures into the UserForm1 module, and then add UserForm2. UserForm1's caption is created in its Activate event procedure. When the user clicks the client area of UserForm1, UserForm2 is loaded and shown triggering UserForm1's Deactivate event, changing their captions.

See also

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.

Select vs. Activate

One question I hear often from new members of our VBA Pro Course is, “What's the difference between Select and Activate? It seems like they do the same thing?”

Which Method Should I Use?

First, it's important to note that both methods can be used on many different types of objects in Excel. This includes sheets, ranges, cells, shapes, charts, slicers, etc. We'll use worksheets in this example.

Activate for Workbooks

The Activate method is also used when activating Workbooks and Windows. There is no Select method for these objects.

Avoid Select and Activate Whenever Possible

It's great to know the difference between these two methods, but you might not need them as often as you think. Especially if you are just starting out with VBA and using the macro recorder a lot.


It's best to use Select when you want to select a single object or multiple objects. Activate should be used when you want to activate (view/select) an object within an existing selection. Activate is also used to select Workbooks, as there is not Select method for that object.

Why we need to activate a Workbook using VBA?

When we deal with multiple workbooks and if you want to read or write to a specific workbook. You can easily activate a workbook using VBA. And do whatever tasks which you want to do.

VBA Activate Workbook – Syntax

Here is the example syntax to activate a Workbook using VBA. You can use either a Workbook name or Workbook number. When we specify the workbook number if it the order of the workbooks which you are opening.

VBA Activate Workbook – with Name:Example 1

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

VBA Activate Workbook – with Number:Example 2

Please see the below VBA codes to activate a Workbook using workbook number. In this example we are activating a workbook 2 in the currently opened workbooks collection.

VBA Activate Workbook – ThisWorkbook:Example 2

Please see the below VBA codes to activate a currently running macro workbook. This will be very useful while dealing with the multiple workbooks.

VBA ActiveWorkbook Object

We can refer the currently activated Excel Workbook using Excel VBA ActiveWorkbook object. ActiveWorkbook VBA object is very usefull while automating tasks and working on currently active Excel WorkBook in the active workbook window.

Set ActiveWorkbook in Excel VBA

It is very useful to refer the Active Eorkbook in Excel VBA by setting into a Variable. We can assign and set ActiveWorkbook to an object and refer at any place of the procedure. Here is the syntax to Set ActiveWorkbook in VBA.

What does AppActivate do?

The AppActivate statement changes the focus to the named application or window but does not affect whether it is maximized or minimized. Focus moves from the activated application window when the user takes some action to change the focus or close the window.

What is the default drive name for AppActivate?

The Shell statements assume that the applications are in the paths specified. On the Macintosh, the default drive name is "HD" and portions of the pathname are separated by colons instead of backslashes.