![]() |
return row number
Hi,
How can I return the row number (in VB inside a macro) of the last data-containing cell in a particular column? Thanks for any help, Jon |
return row number
Jon,
Try something like the following: Dim RowNum As Long RowNum = Cells(Rows.Count,"A").End(xlUp).Row Change the "A" to the column of interest. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jonathan Vickers" wrote in message ... Hi, How can I return the row number (in VB inside a macro) of the last data-containing cell in a particular column? Thanks for any help, Jon |
return row number
Thanks for the help, Chip.
I want to use the result in the next part of the code in place of the 400: Rows("6:400").Sort .............. but it doesn't seem to work. Is there something else that I need to do, or should I be approaching this in another way? Thanks once again for any help, Jon "Chip Pearson" wrote in message ... Jon, Try something like the following: Dim RowNum As Long RowNum = Cells(Rows.Count,"A").End(xlUp).Row Change the "A" to the column of interest. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jonathan Vickers" wrote in message ... Hi, How can I return the row number (in VB inside a macro) of the last data-containing cell in a particular column? Thanks for any help, Jon |
return row number
Rows("6:" & rowNum).Sort
demo'd from the immediate window: rowNum = 600 ? Rows("6:" & rowNum).Address $6:$600 -- Regards, Tom Ogilvy "Jonathan Vickers" wrote in message ... Thanks for the help, Chip. I want to use the result in the next part of the code in place of the 400: Rows("6:400").Sort .............. but it doesn't seem to work. Is there something else that I need to do, or should I be approaching this in another way? Thanks once again for any help, Jon "Chip Pearson" wrote in message ... Jon, Try something like the following: Dim RowNum As Long RowNum = Cells(Rows.Count,"A").End(xlUp).Row Change the "A" to the column of interest. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jonathan Vickers" wrote in message ... Hi, How can I return the row number (in VB inside a macro) of the last data-containing cell in a particular column? Thanks for any help, Jon |
All times are GMT +1. The time now is 07:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com