Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Everyone
In Excel I can place the following in a cell to get the last non blank row number in column A. This works great and it's super quick. =ROW(OFFSET(A1,COUNTA(A:A)-1,0)) To do the same with VBA code seems very complex. Can you please show me some VBA code that will give me the last non-blank row number for a given column? Andy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Andy
What your formula actually does is count how many non blanks there are in column A, and give the row number of the cell that is offset one less than that number from cell A1; which, if there are no blanks cells in column A turns out to be the last non blank row number. If there are any blanks, it won't give the number you want. To replicate the functionality you described in VBA is pretty easy. All you have to do is go to the bottom of the spreadsheet, end up to the last non blank row with something in it. You don't say what you want to do with the number, but Sub Macro2() MsgBox Cells(Rows.Count, 1).End(xlUp).Row End Sub will tell you what the number is. I hope this helps. Ken On Apr 6, 3:52*pm, Andy wrote: Hi Everyone In Excel I can place the following in a cell to get the last non blank row number in column A. *This works great and it's super quick. =ROW(OFFSET(A1,COUNTA(A:A)-1,0)) To do the same with VBA code seems very complex. *Can you please show me some VBA code that will give me the last non-blank row number for a given column? Andy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excellent!! Thanks Ken.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
row number of last non-blank cell | Excel Worksheet Functions | |||
Maximum Number of Blank Cells between Non Blank Cells in a Range | Excel Worksheet Functions | |||
How to find the first non-blank number in a row? | Excel Worksheet Functions | |||
BLANK SPACE TO A NUMBER | Excel Worksheet Functions | |||
First non blank number in a row | Excel Discussion (Misc queries) |