Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Select vs Activate

Tags:

excel

vba

What is the difference between the VBA code wb.Sheets(1).Cells.Select and wb.Sheets(1).Activate?

like image 765
Bruno Avatar asked Aug 24 '11 17:08

Bruno


People also ask

What is difference between select and activate 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.

What is activate in Excel?

VBA Activate Worksheet method is used to makes the current sheet as active sheet. Here we are the examples using Activate method of worksheet object in VBA. It is very frequently used method while writing VBA macros. We also see the VBA ActiveSheet object with examples.

Can you select a worksheet without activating it?

Before you can use the Selection property successfully, you must activate a workbook, activate or select a sheet, and then select a range (or other object) using the Select method. The macro recorder will often create a macro that uses the Select method and the Selection property.

What does it mean to activate a workbook?

To activate a workbook using VBA, you need to use the Workbook. Activate method. In this method, you need to specify the workbook name using the Workbook object. It also allows you to use the workbook number instead of the workbook name, but you can only refer to the open workbooks.


1 Answers

Difference between select is that you can select several objects at once. Objects that are selected are also placed in the Selection object which you can use methods on. Unless you are selecting multiple objects, selecting (say, a cell) activates the object.

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."

Note: They both have one thing in common - they are rarely ever needed and they do generally don't do anything but slow your code down. You can work directly on an object without selecting or activating it and it's best practice not to use these unless needed.

like image 123
aevanko Avatar answered Sep 23 '22 04:09

aevanko