Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Sheets.Select and Sheets.Activate?

In VBA for Excel, what is the difference between Sheets.Select and Sheets.Activate ?

like image 405
Mehper C. Palavuzlar Avatar asked Apr 10 '13 07:04

Mehper C. Palavuzlar


People also ask

What does worksheet activate do?

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

What are active sheets in Excel?

The ActiveSheet is the worksheet tab that is currently selected before running the macro. If multiple sheets are selected, the ActiveSheet is the sheet that is currently being viewed.

How do you make an Excel sheet active?

By keyboard: First, press F6 to activate the sheet tabs. Next, use the left or right arrow keys to select the sheet you want, then you can use Ctrl+Space to select that sheet.

What does it mean to activate a workbook in VBA?

VBA Workbook Activate method will help us to activate a specific Workbook. It is helpful when we have opened multiple workbooks and want to access a particular workbook to manipulate or read some data from the Active Workbook.


1 Answers

The difference is in their flexibility.

Activate make the specified sheet the active sheet, and may only be applied to a single sheet

Select allow for optionally extending the currently selected sheets to include the specified sheet, eg

Worksheets("Sheet2").Select Replace:=False

and also allow for selecting an array of sheets

Sheets(Array("Sheet3", "Sheet2")).Select

In their minimal form Select and Activate do the same thing.

For example, if only one sheet is currently selected (say Sheet3) or if more than one sheet is selected but excluding say Sheet2, then Worksheets("Sheet2").Select and Worksheets("Sheet2").Activate both make Sheet2 the sole selected and active sheet.

On the other hand, if say both Sheet2 and Sheet3 are selected and Sheet2 is the active sheet, then Worksheets("Sheet3").Activate leaves both sheets selected and makes Sheet3 the active sheet, whereas Worksheets("Sheet2").Select makes Sheet3 the sole selected and active sheet.

like image 163
chris neilsen Avatar answered Oct 06 '22 01:10

chris neilsen