Excel Formula to find last row

Could someone help me with an excel formula to find the last row in column A even if the data has blanks scattered throughout?

Thanks in advance.

Scott Barnes
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Formula Solution:

The following formula will return you the row of last cell with data in the range A1:A20

Open in new window

VBA Solution:

The following code will return you the last row with data in col. A
Sub FindLastRowWithData_1()
Dim LR As Long
LR = Cells(Rows.Count, "A").End(xlUp).Row
MsgBox LR
End Sub

Open in new window

Martin LissOlder than dirtCommented:
If you remove the numbers from sktneers' formula it's more flexible.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ScottBarnesAuthor Commented:
Sorry for not specifying but I need to be able do this using a formula, not vba, it will be used in name manager for a pivot table.  The trick is that the data will sometimes have blanks.  If row 10 is blank and row 11 had data again, I don't want it to return that 9 is the last row.

Currently I'm using this and it doesn't work correctly when there are blanks.


Thank you,
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Martin LissOlder than dirtCommented:
Please see my previous post.
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Try this.....


Open in new window

Martin LissOlder than dirtCommented:
@Scott: Please consider Requesting Attention so that you can split the points between sktneer and I since all I did was to modify his formula.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.