在复制/粘贴function时出现运行时错误1004

试图编译这个时,我不断收到这个错误。 什么是正确的方法来复制单元格并粘贴到另一个表单?

Sub copypaste()

Dim col As Integer Dim row As Integer Dim copy As String Dim newrow As Integer Dim wrksht As Integer wrksht = 3 newrow = 1 For col = 23 To 1 Step -1 Worksheets(3).Cells(33, col).copy Worksheets(17).Cells(row, 1).PasteSpecial Transpose:=True For row = 31 To 1 Step -1 If Worksheets(3).Cells(row, col).Value = "x" Then Worksheets(17).Cells(newrow, 2).Value = Worksheets(12).Cells(row, 25).Value newrow = newrow + 1 End If Next row Next col 

结束小组

在你的行中:

 Worksheets(17).Cells(row, 1).PasteSpecial Transpose:=True 

您正在尝试引用一个单元格使用variables行之前给它一个值。 这可能是什么导致你的错误。