Using the CurrentRegion property in VBA
我想编写一个简单的VBA宏,以在与Sheet1中活动单元周围的单元块相对应的范围内复制数据,并将其粘贴到Sheet2中。 (最好使用与Sheet1相同的地址)。
我写的代码是:
1 2 3 4 5 6 7 | Option Explicit Dim Cello As Range Sub CopyCurrentRegion2() Set Cello = Worksheets("Sheet1").Range(ActiveCell.Address) Cello.CurrentRegion.Copy Sheets("Sheet2").Range(Cello) End Sub |
请更正此编。 它给出运行时错误:1004。
考虑:
1 2 3 4 5 | Sub CopyStuff() With ActiveCell.CurrentRegion .Copy Sheets("Sheet2").Range(.Address) End With End Sub |