VBA: Selecting range by variables

前端 未结 6 904
甜味超标
甜味超标 2020-12-02 21:28

I want to select the formatted range of an Excel sheet. To define the last and first row I use the following functions:

lastColumn = ActiveSheet.UsedRange.Co         


        
6条回答
  •  暖寄归人
    2020-12-02 22:00

    You're missing a close parenthesis, I.E. you aren't closing Range().

    Try this Range(cells(1, 1), cells(lastRow, lastColumn)).Select

    But you should really look at the other answer from Dick Kusleika for possible alternatives that may serve you better. Specifically, ActiveSheet.UsedRange.Select which has the same end result as your code.

提交回复
热议问题