VBA Selecting a Range: How to Do It in Excel

VBA & macros · Updated November 23, 2026

To select a range in Excel VBA, use the Range object with the Select method, for example Range("A1:B10").Select. This highlights the specified cells on the active worksheet, and you can also use Cells, Rows, Columns, or Union to build more complex selections before calling Select.

Why Selecting a Range Matters in VBA

Selecting a range is one of the first things beginners learn because it mimics what you do manually in Excel. However, in VBA, selecting is often unnecessary and can slow down your code. Most operations—like reading values, formatting, or applying formulas—can be done directly on the Range object without selecting it first. Selecting is mainly useful when you want to visually show the user which cells are affected, or when you need to activate a range before using certain commands like Find or Sort that rely on the active selection.

Basic Ways to Select a Range

The simplest form is a fixed address. With Sheet1 active, Range("C5:E8").Select selects cells C5 through E8. You can also use the Cells property to select by row and column numbers: Cells(5, 3).Select selects cell C5 (row 5, column 3). To select a larger block using Cells, combine them with Range: Range(Cells(1, 1), Cells(10, 5)).Select selects A1:E10. This is useful when you don’t know the exact address in advance, for example when the last row is dynamic.

Selecting Entire Rows, Columns, or the Used Range

To select an entire row, use Rows(3).Select for row 3, or Rows("3:5").Select for rows 3 through 5. Similarly, Columns("B").Select selects column B, and Columns("B:D").Select selects columns B through D. To select all cells that contain data on a sheet, use ActiveSheet.UsedRange.Select. This is handy when your data size changes each time you run the macro. For the current region around a cell (contiguous data block), use Range("A1").CurrentRegion.Select—this selects the rectangle of non-empty cells surrounding A1, similar to pressing Ctrl+Shift+*.

Selecting Non-Contiguous Ranges and Multiple Areas

Sometimes you need to select cells that aren’t next to each other, like A1:A5 and C1:C5. Use the Union method: Union(Range("A1:A5"), Range("C1:C5")).Select. This creates a single Range object with two areas. You can also use the Range property with a comma-separated string: Range("A1:A5, C1:C5").Select. Both work, but Union is more flexible when you’re building the selection dynamically in a loop. To select an entire row across multiple sheets, you’d need to select on each sheet individually, because a selection is per-worksheet.

How to Select a Range Based on a Variable

In most real macros, the range isn’t fixed. For example, you might want to select from A1 down to the last non-empty cell in column A. Use End like this: Range("A1", Range("A1").End(xlDown)).Select. This is equivalent to pressing Ctrl+Shift+Down from A1. To find the last used row in a column more reliably, use Cells(Rows.Count, 1).End(xlUp).Row and then select: Range("A1:A" & lastRow).Select. Here’s a full example that assumes data in column A starting at row 1:

Dim lastRow As Long
lastRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:A" & lastRow).Select

This works even if the data has gaps, because it starts from the bottom of the sheet and goes up. Remember to save a copy of your workbook before running macros, as selecting itself is harmless but the subsequent code might change data—and macros cannot be undone with Ctrl+Z.

Common Problems When Selecting Ranges

One frequent issue is getting an error when the worksheet isn’t active. Select only works on the active sheet. If you try to select a range on a sheet that isn’t active, you’ll get a runtime error 1004. To fix this, activate the sheet first: Sheets("Data").Activate then Range("A1").Select. Another problem is selecting a range on a chart sheet or a protected sheet—protection can block selection. Also, if you use Select inside a loop, it can be extremely slow because each selection refreshes the screen. A better approach is to turn off screen updating with Application.ScreenUpdating = False before the loop and set it back to True after. For simple operations, avoid Select entirely and work directly with the Range object, like Range("A1").Value = 5.

Comparing Select vs. Activate vs. Direct Access

Many beginners confuse Select and Activate. Select can select multiple cells, while Activate can only activate a single cell within the selection. For example, Range("A1:B2").Select selects four cells, but Range("A1:B2").Activate activates only A1 (the top-left cell). Direct access without selecting is almost always faster and cleaner. Instead of selecting a range to change its font, you can write Range("A1:B10").Font.Bold = True. This avoids the overhead of selection and doesn’t depend on which sheet is active. For most tasks, direct access is the recommended practice in VBA programming.

Frequently Asked Questions

How do I select a range that is on another sheet?
You must first activate that sheet, because Select only works on the active sheet. Use Sheets("Sheet2").Activate then Range("A1:B5").Select. Alternatively, you can avoid selecting altogether and just reference the sheet directly, like Sheets("Sheet2").Range("A1").Value = 10.

Can I select a range without activating the worksheet?
No, the Select method requires the worksheet to be active. If you need to highlight cells on an inactive sheet, you’d have to activate it first. However, you can still manipulate the range (change values, format, etc.) without activating it.

What’s the difference between Range.Select and Cells.Select?
Range.Select uses an address like “A1:B2”, while Cells.Select uses row and column numbers. For example, Cells(1, 1).Select selects A1. Both result in a selection, but Cells is easier to use with variables for row and column numbers.

Why does my code error when I use .Select on a range?
The most common reason is that the sheet isn’t active. Another cause is that the worksheet is protected, or the range is on a chart sheet. Also, if you’re in a user form or a non-worksheet context, Select won’t work. Check that you’ve activated the correct sheet and that the workbook isn’t in a state where selection is disabled.

Is it bad practice to use .Select in VBA?
It’s not inherently bad, but it’s often unnecessary. Using Select slows down code and can cause errors if the wrong sheet is active. Most experienced VBA developers avoid it unless they specifically need to change the user’s selection. For most tasks, you can directly operate on the Range object without selecting it.

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.