0

我正在尝试从订单表复制到 Log 2018 表。
电子表格已经打开,我将激活它。
要复制的第一行是第 6 行。C 列将始终包含数据。

我想从 C6 中找到下一个空列。

Windows("Log 2018").Active
Sheets("Log 2018").Range("C6").End(xlDown).Offset(1,-1).Select
Application.CutCopyMode = False
Selection.Copy
indows("Order Sheet.xls".Active
Sheets("Order Input").Range("E4".Cells.PastgeSpecial xlAll
Application.CutCopyMode = False

第二行高亮显示

应用程序和对象定义的错误

4

1 回答 1

1

Took me a couple times, but i believe you wrote that the second line is giving you the error. To fix that would also correct this whole section:

Windows("Log 2018").Active
Sheets("Log 2018").Range("C6").End(xlDown).Offset(1,-1).Select 'THIS ONE
Application.CutCopyMode = False
Selection.Copy

I would recommend the following:

'to clean up all of the above code
dim lr as long
with Sheets("Log 2018")
    lr = .cells(6,"C").end(xlDown).Row
    .cells(lr+1,"B").Copy 'Wrote this based on your Offset of -1 col, +1 row
end with
'this would be your current paste from here down
Sheets("Order Input").cells(4,"E").PasteSpecial xlAll

Note that you don't need to activate the sheets if you're using them, nor use select to perform operations.

于 2018-08-23T15:50:02.580 回答