We help IT Professionals succeed at work.

Row number of last non null value in one excel column

Last Modified: 2012-05-03
I am using Access 2010 I need to find last non null value in column “A” in my excel file.
My excel file –workbook is on C:\Inventory\Name_aa.xlsx.
In my Name_aa.xlsx workbook I have two worksheets. I need info from first worksheet , one named” Validation” and its column “A”.
To be precise I need function to give me row number of last non null values of this column.
I need this as  VBA code not as excel solution,,INDEX MATCH and ….
Watch Question

Top Expert 2009
This one is on us!
(Get your first solution completely free - no credit card required)

You could use some code like this. It displays a message of the last non-null row in column 1 ("A"):

MsgBox ThisWorkbook.Sheets("Validation").Cells(Rows.Count, 1).End(xlUp).Row

Open in new window


I believe something like this should help you.
Sub get_last_non_null_row_value()
    Dim rowValue As Long
    rowValue = ActiveCell.Row
    'instead of displaying this dialog box, you might want to populate 
    'the value somewhere else in the workbook or return the value to a calling function, etc.
    MsgBox "last row value is " & rowValue
End Sub

Open in new window

I should point out that this example assumes there are no null values in between non-null values in column A. If there are null values in between non-null values, it will return the row value of the row just above the first null value.

Good luck!


I am not sure why this happening, however I am getting not correct result , I am getting value of last rows in my worksheet.
I can see that last value is seating in A15, after that cells in column A are empty, however I got as result of function  last row is 378 is that because there is formula behind in every filed in column A. “=IFERROR(…..and on
Top Expert 2009

Are you defining a cell being Null as strictly that (it contains a Null), or perhaps thinking of empty cells, or cells with empty strings in them?  (or formulas, for that matter?)  I was testing in a workbook with no formulas.
Top Expert 2009

Can you post the workbook for testing?


here is formula behind all those cells in Column "A".
I picked up just cell A16 as it was first empty cell after A15.

If I go to cell A17 it has :
=IFERROR(INDEX(Parts_detail,$A17,COLUMN()-1),"") and on.
It looks if it hit error it should show  ""  empty string.
I was not right when I said last cell with “ non null” value. I made mistake, sorry.
For me row number of last not empty cell in column “A” is row which shows visible data in column “A” cell.
In my case it is A15
It is not row number of column “A” cell  that do not show data and has formula in or has empty string “” which is not visible.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.