ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using last row in macros (https://www.excelbanter.com/excel-discussion-misc-queries/126930-using-last-row-macros.html)

robertlewis

Using last row in macros
 
I want to be able to select the last row which contains data and use the row
number in a macro to select all the cells in a column from the top to the
last row. The number of rows varies each time the macro is run.

Mike

Using last row in macros
 
Number = ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row

"robertlewis" wrote:

I want to be able to select the last row which contains data and use the row
number in a macro to select all the cells in a column from the top to the
last row. The number of rows varies each time the macro is run.


Don Guillett

Using last row in macros
 

lr=cells(rows.count,"a").end(xlup).row
range(cells(1,"a"),cells(lr,"a")).copy range("b3")

You rarely need to select but if you insist
lr=cells(rows.count,"a").end(xlup).row
range(cells(1,"a"),cells(lr,"a")).select

--
Don Guillett
SalesAid Software

"robertlewis" wrote in message
...
I want to be able to select the last row which contains data and use the
row
number in a macro to select all the cells in a column from the top to the
last row. The number of rows varies each time the macro is run.





All times are GMT +1. The time now is 04:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com