Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Selecting a Range of Cells Relative to the Current Cell.

Selecting a Range of Cells Relative to the Current Cell

by Allen Wyatt
(last updated March 11, 2017)


Sometimes in a macro it is helpful to select cells relative to whichever cell is currently selected. For instance, let's say you want to select the first three cells of the current row. You can do that by using the following VBA code:

Range(Cells(Selection.Row, 1), Cells(Selection.Row, 3)).Select

The Cells property returns an object that represents a specific row and column (individual cell) of a worksheet. In this usage, Cells is used twice to determine a specific range of cells. The first instance returns the first cell of the current row, while the second returns the third cell of the current row. Thus, the range becomes the first through third cells of the current row.

Instead of using the Cells property to specify a location, you can use the Offset property to accomplish much of the same task. Consider the following code:

Range(ActiveCell.Offset(-3, 5), ActiveCell.Offset(0, 10)).Select

This uses the Offset property of the ActiveCell object to specify a range relative to the currently selected cell. The Offset property takes an argument that represents the row and column of the offset. A negative value represents up (for the row) and left (for the column). A positive value is down (for the row) and right (for the column). You can also use a value of 0, which represents the current row or column.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2268) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Selecting a Range of Cells Relative to the Current Cell.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Basing Headers and Footers on the Previous Section

Word treats the headers and footers in a document independently, based on the section in which they appear. This means that ...

Discover More

Using the Keyboard to Select and Resize a Chart Object

When working with charts and chart objects, Excel is very dependent on the mouse. If you don't want to use the mouse, but ...

Discover More

Preventing Jumbled Sorts

Click the Sort tool in Excel, and you may be surprised that the data in your worksheet is jumbled. In order to sort ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Opening a Workbook but Disabling Macros

Macros that run automatically when you open or close a workbook are quite helpful. You may not want them to run, however, ...

Discover More

Switching Windows in a Macro

When you have multiple workbooks open at the same time, Excel allows you to easily switch between those workbooks. How you do ...

Discover More

Exiting a For ... Next Loop Early

If you use For ... Next loops in your macros, make sure you give a way to jump out of the loop early. That way you can limit ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 0?

2017-04-25 09:08:05


Hi Barry,
I find Selection, ActiveCell, ActiveSheet and the such very useful in the first instance to refer to the thing currently “active”. ( For example to determine what someone may have selected as “where” something should go).
But I totally agree that in many cases it is a good idea to assign that “active” thing to a variable as soon as possible, after which refer to that rather than further using a reference to the “active” thing
I always prefer to do as you suggest.

Another reason for doing this is to be using specifically a Range object, or a property thereof.
I had a lot of discussions recently about whether or not we actually have a Cells(row, column) Property at all.
Cells returns a Range object of all the cells of the object to which it applies. Then we typically are using the Range object Property on that returned Range object.
So Cells(row, column) relies on implicit defaults etc to actually use the Range object Item Property on the returned Range object from the Cells Property
I got into some heated discussions with many experts who had split opinions about that.
So getting at an early stage to a Range object helped me circumvent all that .. lol.. – Everyone agreed then that I was working after that on a Range object. :)

2017-04-24 05:21:15


I am not in favour of using the Selection object as it is poor programming practice, and especially not moving it as it can confuse the User, and it can cause run-time errors. There are a few exceptions to this naturally.

Note: using the Selection object implies the top left cell for functions/methods that only require a single cell; more often than not this is also the Activecell but is is not necessarily the case. [Try selecting a range of cells on a worksheet then press the Tab key to see the Activecell move but the Selection remains the same.]

If you actually want to reference a range relative to the currently selected cell(s) then I would use the following:

Set rng = Selection.Offset(3,4) 'Note this preserves the range of cells if multiple cells are selected.

Use "Set rng = Selection.Range("A1").Offset(3,4) ' if you only want to reference a single cell relative the to the top left cell of the selection.

then in subsequent code use the 'rng' object instead of the 'Selection' object.

NOTE: if Option Explicit is used (highly recommended) then 'rng' will need to be defined using a DIM statement.

2017-04-23 05:11:04

Vempati Satya Suryanarayana

Hi Allen you are to the point and your explanation is simple. After a lot of search I found your tip. And my problem is solved

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.