Return a range from A1 to the true last used cell

后端 未结 4 743
名媛妹妹
名媛妹妹 2020-11-27 05:48

I\'d like to select all the rows and columns in a spreadsheet. The macro needs to be dynamic, as the number of columns and rows tend to vary each time the macro would be cal

4条回答
  •  庸人自扰
    2020-11-27 06:26

    Selecting A1 to the last cell used (including blanks in-between) in Column A is as simple as this:

    Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row).Select
    

    To select A1 to the last cell used in the entire sheet (regardless if it's used in column A or not):

    Range("A1:A" & ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row).Select
    

提交回复
热议问题