Taras
asked on
Row number of last non null value in one excel column
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 ….
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 ….
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Taras,
I believe something like this should help you.
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 believe something like this should help you.
Sub get_last_non_null_row_value()
Dim rowValue As Long
sheets("Validation").select
Range("A1").Select
Selection.End(xlDown).Select
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
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!
ASKER
Helen.
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
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
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.
Can you post the workbook for testing?
ASKER
here is formula behind all those cells in Column "A".
I picked up just cell A16 as it was first empty cell after A15.
=IFERROR(INDEX(Parts_detai l,$A16,COL UMN()-1)," ").
If I go to cell A17 it has :
=IFERROR(INDEX(Parts_detai l,$A17,COL UMN()-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.
I picked up just cell A16 as it was first empty cell after A15.
=IFERROR(INDEX(Parts_detai
If I go to cell A17 it has :
=IFERROR(INDEX(Parts_detai
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.
Open in new window