Excel VBA: Selecting All Sheets

Sometimes we need to select all the sheets on an active workbook when we make a VBA macro.

Macro Examples

The following Excel VBA macro selects all the sheets.

Sub SelectAllSheets()

  Sheets.Select

End Sub

Description

We need only the following code:

  Sheets.Select

I will explain about this simple code.

[Application.]Sheets

  Sheets...

The Application.Sheets property returns the Sheets collection object that represents all the sheets in a workbook.

obj-Excel-Application-Sheets

The Application.Sheets property is a member of the Excel.Global class, so we can omit the Application property.

obj-Excel-Global-Sheets

Sheets.Select

  Sheets.Select

The Sheets.Select method selects all the sheets without looping.

obj-Excel-Sheets-Select

Sub SelectAllSheets()

  Sheets.Select

End Sub

That’s all.

Properties

http://www.relief.jp/itnote/archives/018108.php

Apply to

  • Excel 2013
  • Excel 2010
  • Excel 2007