Selecting Cells using Excel VBA Macros - Absolute
Part two of a four-part series of blogs

This blog gives the various possible ways to select cells, ranges, columns and rows using Visual Basic for Applications in Excel. Useful for the VBA newbie, but even gurus might find one or two commands they'd missed!

1. Selecting Cells in Excel Visual Basic Macros (Absolute)
2. Absolute Selection - the Common Excel VBA Commands (this blog)
3. Selecting Rows, Columns and Entire Worksheets
4. Less Common Absolute Selection Commands

This blog is part of our Excel macros online tutorial series.  For real-world training, book onto our introductory or advanced VBA or Excel courses.

Posted by Andy Brown on 11 August 2011

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

# Absolute Selection - the Common Excel VBA Commands

You want to go to a cell or range of cells using a macro written in Visual Basic for Applications within Excel.  Here's how!

For all of the examples below, assume that you want to select the cell containing Pooh Bear (who wouldn't?).

## Selecting a Single Cell

There are two ways to select a single cell.  You can either do it by cell reference:

Sub SelectPoohBear()

'select cell B5 (it's not case sensitive)

Range("B5").Select

End Sub

Or you can do it using the row and column number:

Sub SelectPoohBear2()

'select row 5, column 2

Cells(5, 2).Select

End Sub

Either way works fine - the choice is up to you.

The method using Cells(row,column) can be particularly useful when looping over cells, since the row and column can be variables.

## Selecting a Block of Cells

If you've got a block of cells, you can select them by cell reference or by range name:

In this case we want to select the range from B3 to B11, which also has the range name Characters.

To select a range of cells by reference, use a colon to separate the start and end cell:

Sub SelectCharacters()

'again, this isn't case sensitive

Range("B3:B11").Select

End Sub

Alternatively, you could use the range name, where (as here) one exists:

Sub SelectCharacters()

'type the range name in quotes

Range("Characters").Select

End Sub

Now it's time to look at some less common selection commands ...