且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将偏移行添加到给定范围. Excel VBA

更新时间:2023-12-06 11:36:40

您将myRows作为Variant数据类型.您需要将其声明为Range对象.

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

Dim myRows as Range

然后,您需要使用Set关键字来分配Range对象).

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

Set myRows = Range("1:10")

然后,使用范围.Resize方法:

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

否则,如果您需要将myRows保持为Variant类型,请告知我,我可以对其进行重新处理.

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