Meaning of .Cells(.Rows.Count,”A”).End(xlUp).row

calendar_today Asked Nov 21, 2014
thumb_up 18 upvotes
history Updated April 14, 2026

Direct Answer

It is used to find the how many rows contain data in a worksheet that contains data in the column "A". The full usage is lastRowIndex = ws.Cells(ws.Rows.Count, "A").End(xlUp).row…. This is an advisory response with reference links, ranked #69th of 303 by community upvote score, from 2014.


The Problem (Q-score 7, ranked #69th of 303 in the Excel VBA archive)

The scenario as originally posted in 2014

I was just wondering if you could help me better understand what .Cells(.Rows.Count,"A").End(xlUp).row does. I understand the portion before the .End part.

Why this Range / Worksheet targeting trips people up

The question centers on reaching a specific cell, range, or workbook object. In Excel VBA, this is the #1 source of failures after activation events: every property (.Value, .Formula, .Address) behaves differently depending on whether the parent Workbook is explicit or implicit.


The Verified Solution — strong answer (top 25 %%) (+18)

Advisory answer — community consensus with reference links

Note: the verified answer below is a reference / advisory response rather than a copy-ready snippet.

It is used to find the how many rows contain data in a worksheet that contains data in the column “A”. The full usage is

 lastRowIndex = ws.Cells(ws.Rows.Count, "A").End(xlUp).row

Where ws is a Worksheet object. In the questions example it was implied that the statement was inside a With block

With ws
    lastRowIndex = .Cells(.Rows.Count, "A").End(xlUp).row
End With
  1. ws.Rows.Count returns the total count of rows in the worksheet (1048576 in Excel 2010).
  2. .Cells(.Rows.Count, "A") returns the bottom most cell in column “A” in the worksheet

Then there is the End method. The documentation is ambiguous as to what it does.

Returns a Range object that represents the cell at the end of the region that contains the source range

Particularly it doesn’t define what a “region” is. My understanding is a region is a contiguous range of non-empty cells. So the expected usage is to start from a cell in a region and find the last cell in that region in that direction from the original cell. However there are multiple exceptions for when you don’t use it like that:

  • If the range is multiple cells, it will use the region of rng.cells(1,1).
  • If the range isn’t in a region, or the range is already at the end of the region, then it will travel along the direction until it enters a region and return the first encountered cell in that region.
  • If it encounters the edge of the worksheet it will return the cell on the edge of that worksheet.

So Range.End is not a trivial function.

  1. .row returns the row index of that cell.


When to Use It — classic (2013–2016)

Ranked #69th in its category — specialized fit

This pattern sits in the 95% tail relative to the top answer. Reach for it when your scenario closely matches the question title; otherwise browse the Excel VBA archive for a higher-consensus alternative.

What changed between 2014 and 2026

The answer is 12 years old. The Excel VBA object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.

help
Frequently Asked Questions

Why does this sit in the top quartile of Excel VBA answers?
expand_more

Answer score +18 vs the Excel VBA archive median ~6; this entry is strong. The score plus 7 supporting upvotes on the question itself (+7) means the asker and 17 subsequent voters all validated the approach.

This answer links out — what are the reference links worth following?
expand_more

Read the first external link for the canonical reference, then search this archive for a top-10 entry in the same category — advisory answers are best paired with a ranked code snippet to close the loop.

Published around 2014 — what’s changed since?
expand_more

Published 2014, which is 12 year(s) before today’s Office 2026 build. The Excel VBA object model has had no breaking changes in that window. Three things to re-test: (1) blocked macros on downloaded files (Mark-of-the-Web), (2) 64-bit API declarations (PtrSafe, LongPtr), (3) any shift toward Office Scripts for web scenarios.

Which Excel VBA pattern ranks just above this one at #68?
expand_more

The pattern one rank above is “VBA Dialog box to select range in different workbook”. If your use case overlaps, compare both before committing.

Data source: Community-verified Q&A snapshot. Q-score 7, Answer-score 18, original post 2014, ranked #69th of 303 in the Excel VBA archive. Last regenerated April 14, 2026.