我希望将值从 ws1 复制/粘贴到 ws2
具体来说,要从工作表 #1 到工作表 #2 复制 2 列数据的范围,并粘贴在同一列中的交替单元格中。
例子:
Worksheet 1 (from)
Col AM Col AN
Row 25 TEMP01 10001
Row 26 TEMP02 20002
Worksheet 2 (to)
Col A
Row 3 TEMP01
Row 4 10001
Row 5 TEMP02
Row 6 20002
我只是想将一列粘贴到交替的行中,但无济于事。收到一个
“对象变量或未设置块变量”
错误。
Sub Alternate()
Dim wsFrom As Worksheet
Dim wsTo As Worksheet
Dim LR As Long
Dim i As Long
Dim n As Long
With wsFrom
LR = wsFrom.Range("AM" & .Rows.count).End(xlUp).Row
n = 3
For i = 2 To LR
wsFrom.Range("AM" & i).Copy
wsTo.Range("A" & n).PasteSpecial xlPasteValues
n = n + 2
Next i
End With
End Sub