30 Advanced Excel Tips for 2026

Excel Champs / VBA / How to use ActiveCell in VBA in Excel
By Puneet Gogia (Microsoft MVP)

How to use ActiveCell in VBA in Excel

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

ActiveCell is the one cell with the cursor in it on the active sheet. Read it with MsgBox ActiveCell.Value, write to it with ActiveCell.Value = "Done", and get its position with ActiveCell.Address, ActiveCell.Row and ActiveCell.Column.

When several cells are selected, ActiveCell is still one cell, the white one in the selection, while Selection is the whole block. Use Selection to act on everything selected and ActiveCell for the single cell.

Use Offset to work next to it: ActiveCell.Offset(0, 1).Value = Now writes the date and time in the cell to its right, and Range(ActiveCell, ActiveCell.Offset(4, 2)) is the 5-by-3 block that starts at it. An offset past the edge of the sheet stops with error 1004.

Code that relies on the active cell does something different each time it runs, depending on where the user clicked. For a fixed cell, refer to it by sheet and address, as in Worksheets("Data").Range("B2"). When a chart sheet is active there’s no active cell, and the code can stop with error 91.

In VBA, the active cell is a property that represents the cell that is active at the moment. When you select a cell or navigate to a cell and that green box covers that cell, you can use the ACTIVECELL property to refer to that cell in a VBA code. There are properties and methods that come with it.

use activecell property

Use the Active Cell Property

  1. Type the keyword “ActiveCell”.
  2. Type a dot (.) to get the list of properties and methods.
  3. Select the property or method that you want to use.
  4. Run the code to perform the activity on the active cell.
run the activecell property code

Important Points

  • When you use the ActiveCell property, VBA refers to the active cell of the active workbook’s active sheet, irrespective of how many workbooks are open at the moment.
  • ActiveCell is ultimately a cell that comes with all the properties and methods that a normal cell comes with.

Activate a Cell from the Selected Range

To activate a cell using a VBA code, there are two ways that you can use: the “Activate” method and the “Select” method. When a range is already selected, Activate makes one cell of it active and keeps the whole range selected, while Select would select only that cell.

Sub vba_activecell()

'select and entire range
Range("A1:A10").Select

'select the cell A3 from the selected range
Range("A3").Activate

'clears everything from the active cell
ActiveCell.Clear

End Sub

The above code, first of all, selects the range A1:A10 and then activates cell A3 out of that, and in the end, clears everything from the active cell, i.e., A3.

Return Value from the Active Cell

The following code returns the value from the active cell using a message box.

MsgBox ActiveCell.Value

Or use the following code if you want to get the value from the active cell and paste it into a separate cell.

Range("A1") = ActiveCell.Value

Set Active Cell to a Variable

You can also assign the active cell to a variable, just like in the following example.

Sub vba_activecell()

'declares the variable as range
Dim myCell As Range

'set active cell to the variable
Set myCell = ActiveCell

'enter value in the active cell
myCell.Value = "Done"

End Sub

The variable keeps referring to the same cell even if you select another cell later, which is useful when you want to come back to it.

Get the Row and Column Number of the ActiveCell

With the active cell, there come the Row and Column properties that you can use to get the row and column number of the active cell.

MsgBox ActiveCell.Row

MsgBox ActiveCell.Column

Get Active Cell’s Address

You can use the Address property to get the address of the active cell.

MsgBox ActiveCell.Address

When you run the above code, it shows you a message box with the cell address of the active cell of the active workbook’s active sheet (as I mentioned earlier).

Move from the Active Cell using the Offset

With the Offset property, you can move to a cell that is several rows and columns away from the active cell. The following code selects the cell two rows down and two columns to the right.

ActiveCell.Offset(2, 2).Select

Select a Range from the Active Cell

And you can also select a range starting from the active cell. If the active cell is A1, the following code selects B2:F6.

Range(ActiveCell.Offset(1, 1), ActiveCell.Offset(5, 5)).Select

Loop Down from the Active Cell

A common task is to work through a list starting from the active cell until you reach an empty cell. The following code makes the text of each cell uppercase, from the active cell down to the first blank cell:

Sub loop_from_active_cell()
Dim myCell As Range
Set myCell = ActiveCell
Do While Not IsEmpty(myCell.Value)
myCell.Value = UCase(myCell.Value)
Set myCell = myCell.Offset(1, 0)
Loop
End Sub

It moves the variable down instead of selecting each cell, which is much faster than ActiveCell.Offset(1, 0).Select in a loop.

ActiveCell vs Selection

Selection is everything you have selected, which can be a range of many cells, while ActiveCell is always one cell (the white cell inside the selection). So, ActiveCell.Value = 1 enters 1 only in the active cell, and Selection.Value = 1 enters 1 in all the selected cells.

Frequently Asked Questions

Why do I get error 91 with ActiveCell?

ActiveCell is Nothing when there’s no worksheet active, for example, when a chart sheet is active. Then using it gives the “Object variable or With block variable not set” error (Error 91). Activate a worksheet first.

Can I get the active cell of another sheet?

Not directly, as ActiveCell always belongs to the active sheet. Activate the other sheet first, and then use ActiveCell.

How do I make a cell active without selecting a range?

Use Range(“B5”).Select or Range(“B5”).Activate when no range is selected; both make B5 the active cell. Remember that the sheet of that cell must be active.

Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel