【发布时间】:2018-12-07 09:25:03
【问题描述】:
我正在尝试从我的“主”表中复制数据,然后将其粘贴到我的“csv”表中。但是,当我尝试此操作时,我得到一个运行时错误“'1004': Range 类的 PasteSpecial 方法失败”。
请在下面查看我的代码。出错的是 '.Cells(1, 2).PasteSpecial xlPasteValues'。谢谢。
With main
n = 1
For Each c In .Range("C1:C200")
If c.Value = "x" Then
c1 = Cells(c.Row, Columns.Count).End(xlToLeft).Column
If c1 > 2 Then c.Offset(0, 2).Resize(, c1 - 4).Copy
With csv
If n = 1 Then
.Cells(1, 1) = "ID"
.Cells(1, 2).PasteSpecial xlPasteValues
Else
.Cells(n, 1) = n - 1
.Cells(n, 2).PasteSpecial xlPasteValues
End If
End With
n = n + 1
End If
Next c
End With
【问题讨论】: