billandrew

Well-known Member
Joined
Mar 9, 2014
Messages
743
Hello all

Is there a difference or efficient way to find the last data in a column of the two. In the Forum I see both methods used.

Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

Sheets("Sheet1").cells(Rows.Count, 1).End(xlUp).row
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
To all intents as purposes, there is no difference as far as speed is concern.
 
Upvote 0
Hello all

Is there a difference or efficient way to find the last data in a column of the two. In the Forum I see both methods used.

Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

Sheets("Sheet1").cells(Rows.Count, 1).End(xlUp).row
There is a third way (actually, a second way to use the second example)...

Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row

They all do the same thing. There are two ways to specify a single cell... use the Range object and feed it a cell address in quotes or use the Cells object and specify the row and column designation as two separate arguments. I prefer avoiding concatenations when possible as they require execution time on the part of VB's compiler (although not enough to notice for such a simple concatenation), so my preference is to use Cells when the data permits... and my preference between the two methods of using Cells is to specify the column designation using letters instead of numbers as I find that more self-documenting; think...

Cells(Rows.Count, "CS")

as opposed to...

Cells(Rows.Count, 97)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,305
Members
449,150
Latest member
NyDarR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top