简体   繁体   English

如何根据工作表中的行数选择单元格范围?

[英]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. 我目前有多个数据表,所有数据表的AI列中都有信息,我想在每个数据表中选择一个单元格范围。 Column A varies between 150 rows to 450 rows of data depending on the sheet. 列A在150行到450行数据之间变化,具体取决于工作表。 I want to select columns AI but only up through the last row found in column A. I used the last row function: 我想选择AI列,但只选择A列中的最后一行。我使用了last行功能:

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

How do I get the macro to select columns AI up through the last row? 如何获取宏以选择AI到最后一行? I want it to function as if it was written: 我希望它的功能就像写的一样:

Range("A1:ILastRow").Select

where the "LastRow" is the number of the last column. 其中“ LastRow”是最后一列的编号。

Thanks, James 谢谢,詹姆斯

... You're EXTREMELY close - just use this: ...您非常接近-只需使用以下命令:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何动态选择工作表范围 - How do I dynamically select the range of the sheet 如何选择/编辑一系列单元格? - How do I select/edit a range of cells? 如何根据工作表2中单元格的值从工作表1中复制特定单元格并将其粘贴到工作表2的相应行中? - How do I copy specific cells from sheet 1 and paste into corresponding rows of sheet 2 , based on values of cells in sheet 2? Select 基于不同工作表上行号的单元格范围 - Select Range of cells based on Row Number on a different sheet 如何根据A列中的单词将一个Excel工作表的行导出到新的Excel工作表中 - How do I export rows of one excel sheet into a new excel sheet depending on the word in column A 如何复制/选择带边框的工作表中的单元格范围? - How to copy/select range of cells in a sheet that are enclosed with a border? 选择具有空白行的范围单元格 - Select range cells with blank rows 如何根据VBA中已命名的开始和结束单元格选择单元格范围? - How do I select a range of cells based on named start and end cells in VBA? 在Microsoft Excel中,如何将一排ROWS从sheet1复制到sheet2上的(相等大小)COLUMNS范围内? - In Microsoft Excel, how do I copy a range of ROWS from sheet1 into a range (of equal size) of COLUMNS on sheet2? 执行直到 i = 特定工作表中编号的单元格数 - Do until i = the number of numbered cells in a specific sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM