VBA Select All Cells: How to Select the Used Range

VBA & macros · Updated November 23, 2026

The quickest way to select all cells in an Excel worksheet with VBA is Cells.Select, which selects every cell on the active sheet. For more control, use Range("A1").CurrentRegion.Select to select the contiguous block of data around a cell, or ActiveSheet.UsedRange.Select to select only the rectangle that contains your data.

Why You Might Need to Select All Cells in VBA

Selecting all cells is rarely the final goal—it’s usually a step toward something else. Common reasons include:

  • Applying formatting (fonts, colors, borders) to an entire worksheet.
  • Clearing contents or values before re-populating a sheet.
  • Copying the entire sheet’s data to another location.
  • Setting print area or page setup properties.
  • Deleting unused formatting that bloats the file size.

Understanding how to target the right set of cells—all cells, used range, or current region—saves time and prevents accidental modification of data you didn’t intend to touch.

The Basic Methods: Cells, UsedRange, and CurrentRegion

Excel VBA offers three main ways to reference “all cells,” each with a different meaning:

  • Cells – Refers to every cell on the worksheet (1,048,576 rows × 16,384 columns in modern Excel). Using Cells.Select selects the entire sheet.
  • ActiveSheet.UsedRange – The rectangle that contains all cells that have ever been used (data, formatting, or formulas). This is often what people mean by “all cells with data.”
  • Range("A1").CurrentRegion – The contiguous block of cells that contains data around a starting cell, bounded by empty rows and columns. This is useful when you have a table of data surrounded by blanks.

For example, if your sheet has data in A1:C10, Cells.Select selects the entire grid, while ActiveSheet.UsedRange.Select selects A1:C10 (assuming no stray formatting beyond that).

Step-by-Step: How to Select All Cells with VBA

Here’s a simple macro that selects all cells on the active sheet:

Sub SelectAllCells()
' Selects the entire worksheet
Cells.Select
End Sub

To select the used range instead:

Sub SelectUsedRange()
' Selects only the rectangle that contains data or formatting
ActiveSheet.UsedRange.Select
End Sub

To select the current region around a specific cell (e.g., A1):

Sub SelectCurrentRegion()
' Selects the block of data that includes A1
Range("A1").CurrentRegion.Select
End Sub

These macros work in Excel for Microsoft 365 on Windows. On a Mac, you can run the same code in the VBA editor (press Option+F11 to open it), but the shortcut to run a macro is Option+F8 (instead of Alt+F8 on Windows).

How to Run a VBA Macro That Selects Cells

If you’re new to VBA, here’s the full process:

  1. Press Alt+F11 (Windows) or Option+F11 (Mac) to open the VBA editor.
  2. In the Project Explorer, right-click the sheet you want (e.g., Sheet1) and choose Insert > Module.
  3. Paste the code above into the module window.
  4. Close the editor and press Alt+F8 (Windows) or Option+F8 (Mac) to open the Macro dialog.
  5. Select the macro name (e.g., SelectAllCells) and click Run.

Important: Before running any macro that modifies cells, save a copy of your workbook. Macros cannot be undone with Ctrl+Z, so a backup is essential.

Common Problems and How to Avoid Them

Selecting all cells can cause unexpected issues if you’re not careful:

  • Selecting the entire sheet can be slow – If you have a large sheet, Cells.Select may cause a noticeable delay. Instead, use UsedRange or CurrentRegion when possible.
  • UsedRange may include stray formatting – If you’ve formatted cells far from your data (e.g., accidentally changed font color on row 100000), UsedRange will include that row. Use ActiveSheet.UsedRange.Select only when you’re sure the used range is correct.
  • CurrentRegion stops at blank rows/columns – If your data has blank rows within it, CurrentRegion will only select the first block. For data with gaps, use UsedRange or a dynamic range like Range("A1", Range("A1").End(xlDown)).
  • Selecting all cells can overwrite data – If you use Cells.ClearContents after selecting, you’ll wipe the entire sheet. Always double-check your target range.

Alternatives: Avoiding Select in VBA

While Select works, it’s often inefficient. VBA experts recommend referencing ranges directly without selecting them first. For example, instead of:

Cells.Select
Selection.Font.Bold = True

Use:

Cells.Font.Bold = True

This is faster and reduces errors. Similarly, to clear all cells, use Cells.ClearContents directly. For copying all cells, use Cells.Copy without selecting.

If you need to work with the used range, you can do:

ActiveSheet.UsedRange.Font.Color = RGB(255, 0, 0)

This applies red font to all used cells without selecting them.

Comparing Methods: Which Should You Use?

Here’s a quick comparison to help you choose:

  • Cells.Select – Use when you truly need every cell on the sheet (e.g., to apply a global format).
  • ActiveSheet.UsedRange.Select – Use when you want to target all data and formatting that exists, ignoring empty cells.
  • Range("A1").CurrentRegion.Select – Use when you have a single contiguous table and want to select just that block.

For most tasks, UsedRange is the safest and most practical choice because it avoids the massive selection of the entire sheet while still covering all relevant cells.

Frequently Asked Questions

How do I select all cells in a specific worksheet, not the active one?

Use the worksheet reference directly, e.g., Worksheets("Sheet2").Cells.Select. This selects all cells on Sheet2 regardless of which sheet is active.

Can I select all cells with data only, ignoring blanks?

Yes, use ActiveSheet.UsedRange.Select. This selects the smallest rectangle that contains all non-empty cells (including any formatted but empty cells). If you want only cells with values, you’d need to loop through the used range and check for IsEmpty, but that’s rare.

Does selecting all cells affect performance?

It can. Cells.Select selects over a billion cells, which can cause Excel to lag or freeze temporarily, especially on older machines. Using UsedRange or CurrentRegion is much faster.

How do I select all cells in a column or row?

For a single column, use Columns("A").Select. For a single row, use Rows(1).Select. To select multiple columns, use Columns("A:C").Select.

Can I select all cells and then delete them?

Yes, but be careful. You can use Cells.Clear to remove contents and formatting, or Cells.Delete to shift cells (which may cause errors). For safety, use ActiveSheet.UsedRange.Clear to clear only the used range.

Is there a way to select all cells without VBA?

Yes, you can click the triangle at the intersection of the row and column headers (top-left corner) to select all cells manually. But in VBA, Cells.Select does the same thing.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.