2

寻找使此代码工作的方法:

这个想法是将数据块动态粘贴到工作表的最后使用的单元格下方

具体来说,我正在寻找一种使用偏移函数动态执行此操作的方法

Dim Sit As Long
Set Sit = Cells(Row.Count, 1).End(xlUp).Row

data_sheet1.Range(data_sheet1.Cells(1, iCol), data_sheet1.Cells(iRow, iCol)).Copy Destination:=target_Sheet.Cells(1, TargetCol).Offset(Sit, 0)

非常感谢


Sub test()

Dim Sit As Long
Sit = Cells(Row.Count, 1).End(xlUp).Row

MsgBox (Sit)

End Sub

这是错误所在;我已经隔离了这段代码

4

1 回答 1

0

From MSDN

Set Keyword: In VBA, the Set keyword is necessary to distinguish between assignment of an object and assignment of the default property of the object. Since default properties are not supported in Visual Basic .NET, the Set keyword is not needed and is no longer supported.

See this example

Dim Sit As Long
With target_Sheet
    Sit = .Range("A" & .Rows.Count).End(xlUp).Row + 1
End With

With data_sheet1
    .Range(.Cells(1, iCol), .Cells(iRow, iCol)).Copy _
    target_Sheet.Cells(Sit, TargetCol)
End With
于 2013-05-02T11:50:58.477 回答