30 Advanced Excel Tips for 2026

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

How to use UsedRange Property in VBA in Excel

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

Worksheets("Data").UsedRange is the rectangle from the first to the last cell Excel has recorded as used on the sheet. MsgBox Worksheets("Data").UsedRange.Address shows it, such as $A$1:$F$250, and you can clear, copy or format it like any range.

You don’t need to activate the sheet to use it: Worksheets("Data").UsedRange.Copy Destination:=Worksheets("Backup").Range("A1") works from any sheet. Only .Select needs the sheet to be active.

UsedRange.Rows.Count is the number of rows in the range, not the last row number. When the data starts in row 3 they differ, so get the last row with UsedRange.Row + UsedRange.Rows.Count - 1.

The used range includes cells that only have formatting and cells that once held data and were cleared, so it’s often bigger than your data. For the last row that actually holds a value, use Cells(Rows.Count, "A").End(xlUp).Row or Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious). Deleting the unused rows and columns and then saving shrinks it back.

In VBA, the UsedRange property represents the range in a worksheet that has data in it. The used range starts from the first cell in the worksheet where you have a value and goes to the last cell where you have a value, just like the following example, where you have the used range from A1 to C11. It also includes cells that only have formatting, so it can be bigger than your data.

used range property

Note: UsedRange property is a read-only property.

Write a Code with UsedRange

Use the following code.

  1. First, you need to specify the worksheet.
  2. Then enter a dot (.) and enter “UsedRange”.
  3. After that, use the property or method that you want to use.
  4. In the end, run the code.
Sub vba_used_range()
    ActiveSheet.UsedRange.Clear
End Sub

The above code clears everything from the used range of the active sheet.

Copy UsedRange

Use the following code to copy the entire UsedRange.

copy the entire used range
Sub vba_used_range()

    ActiveSheet.UsedRange.Copy

End Sub

Count Rows and Columns in the UsedRange

There’s a Count property that you can use to count the rows and columns in the used range.

MsgBox ActiveSheet.UsedRange.Rows.Count
MsgBox ActiveSheet.UsedRange.Columns.Count

The above two lines of code show a message box with the count of rows and columns that you have in the used range.

Activate the Last Cell from the UsedRange

You can also activate the last cell from the used range (that would be the last used cell in the worksheet). Consider the following code.

active last cell from the usedrange
Sub vba_used_range()

Dim iCol As Long
Dim iRow As Long

iRow = ActiveSheet.UsedRange.Rows.Count
iCol = ActiveSheet.UsedRange.Columns.Count

ActiveSheet.UsedRange.Select
Selection.Cells(iRow, iCol).Select

End Sub

This code takes the rows and columns count using the UsedRange property and then uses those counts to select the last cell from the used range.

Refer to UsedRange in a Different Worksheet

If you try to select the used range in a worksheet other than the active sheet, VBA will show an error like the following.

usedrange in a different worksheet

So, to select it, the worksheet must be activated first. This is only needed for Select: you can read the address, count the rows, copy or clear the used range of any sheet without activating it, like Worksheets(“Sheet4”).UsedRange.Address.

Sub vba_used_range()

    Worksheets("Sheet4").Activate
    Worksheets("Sheet4").UsedRange.Select

End Sub

And you can’t refer to the used range in a workbook that is closed. But you can open the workbook first and then use the UsedRange property of its worksheet.

Get the Address of the UsedRange

Use the following line of code to get the address of the used range.

Sub vba_used_range()

 MsgBox ActiveSheet.UsedRange.Address

End Sub

Count Empty Cells from the Used Range

The following code uses the FOR LOOPS (For Each) to loop through all the cells in the used range and count the cells that are empty.

Sub vba_used_range()

Dim iCell As Range
Dim iRange As Range
Dim c As Long
Dim i As Long

Set iRange = ActiveSheet.UsedRange

For Each iCell In ActiveSheet.UsedRange

    c = c + 1

    If IsEmpty(iCell) = True Then
        i = i + 1
    End If

Next iCell

MsgBox "There are total " & c & _
" cell(s) in the range, and out of those " & _
i & " cell(s) are empty."

End Sub

When you run this code, it shows a message box with the total count of cells and how many cells are empty out of that.

UsedRange Does Not Always Start at A1

If your data starts at C5, the used range starts at C5 as well. So, UsedRange.Rows.Count gives you the number of rows in the used range, not the number of the last row. To get the real last row and column, add the first row or column of the used range:

Sub used_range_last_row()
Dim lastRow As Long, lastCol As Long
With ActiveSheet.UsedRange
lastRow = .Row + .Rows.Count - 1
lastCol = .Column + .Columns.Count - 1
End With
MsgBox "Last row: " & lastRow & ", last column: " & lastCol
End Sub

Why UsedRange Can Be Bigger Than Your Data

The used range also counts cells that only have formatting and cells where you had data that you have deleted. In that case, it goes beyond your data, which is the same thing you see when Ctrl + End takes you to an empty cell. To fix it, delete the empty rows and columns after your data (not just clear them), and then save the workbook. Excel resets the used range when you save.

If you only need the last row with data, use Cells(Rows.Count, “A”).End(xlUp).Row instead (see find the last row).

Frequently Asked Questions

Can I change the UsedRange?

No, it’s read-only. You can only change it by changing the cells, like deleting the extra rows and columns, and then saving the workbook.

What does UsedRange return on an empty sheet?

It returns cell A1, so UsedRange.Rows.Count is 1 even when the sheet has no data. Check with WorksheetFunction.CountA(ActiveSheet.UsedRange) = 0 if you need to know whether the sheet is empty.

Is UsedRange the same as CurrentRegion?

No. UsedRange covers everything used on the sheet, while CurrentRegion is the block of data around one cell, up to the first empty row and column.

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