简体   繁体   中英

How do I select a range of cells depending on number of rows in the sheet?

I currently have multiple data sheets with information in columns AI in all of them, and I want to select a range of cells in each. Column A varies between 150 rows to 450 rows of data depending on the sheet. I want to select columns AI but only up through the last row found in column A. I used the last row function:

LastRow = Range("A65536").End(xlUp).Row

How do I get the macro to select columns AI up through the last row? I want it to function as if it was written:

Range("A1:ILastRow").Select

where the "LastRow" is the number of the last column.

Thanks, James

... You're EXTREMELY close - just use this:

LastRow = Range("A65536").End(xlUp).Row
Range("A1:I" & LastRow).Select

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM