Adding an Offset Row to a Given Range. Excel VBA

前端 未结 2 890
傲寒
傲寒 2021-01-07 00:10

I have a variable which at the beginning is set to a given range.

I want to have a loop statement that would take the next row down from the end of the given range a

2条回答
  •  忘掉有多难
    2021-01-07 00:58

    You have myRows as a Variant data type. You need to declare it as a Range object.

    Dim myRows as Range

    Then you would need to use the Set keyword to assign a Range object).

    Set myRows = Range("1:10")

    Then, use the range .Resize method:

    Set myRows = myRows.Resize(myRows.Rows.Count+1, myRows.Columns.Count)

    Otherwise, if you need to maintain myRows as type Variant, let me know and I can re-work this.

提交回复
热议问题