Excel VBA Selecting Sheets

In Excel terms, a sheet is any of worksheets, charts, modules, and dialog sheets.


Unqualified Names

When a new workbook is initialized, the following will be accessible objects:

Thus the following is valid:

Sheet1.Range("A1").Value = "foo"

These names do not correspond to any component of the Excel UI. If sheets are renamed or reordered, the sheet formerly known as "Sheet1" remains accessible as Sheet1. If sheets are deleted, then the objects become inaccessible.


Worksheets and Sheets

to activate the first worksheet in the active workbook, try:

Worksheets(1).Activate

To activate the first sheet (of any type) in the active workbook, try:

Sheets(1).Activate

To activate the sheet named "Sheet1" in the active workbook, try:

Sheets("Sheet1").Activate

To select multiple sheets (as for reordering sheets), try:

Sheets(Array("Sheet4", "Sheet5")).Move before:=Sheets(1)


CategoryRicottone

Excel/VBA/SelectingSheets (last edited 2023-01-10 17:30:03 by DominicRicottone)