我希望你能帮助运行时错误1004
我收到运行时错误1004码,我希望你能帮助
我的代码如下。
错误是发生在lastrow = Sheet1.Cells(Rows.Count, 1).End(x1Up).Row
Sub copycolumns()
Dim lastrow As Long, erow As Long
lastrow = Sheet1.Cells(Rows.Count, 1).End(x1Up).Row
For i = 2 To lastrow
If Sheet1.Cells(i, 6) = "Algiers" Then
Sheet1.Cells(i, 1).Copy
erow = Sheet2.Cells(Rows.Count, 1).End(x1Up).Offset(1, 0).Row
Sheet1.Paste Destination:=Worksheets("Sheet2").Cells(erow, 1)
Sheet1.Cells(i, 3).Copy
Sheet1.Paste Destination:=Worksheets("Sheet2").Cells(erow, 2)
Sheet1.Cells(i, 6).Copy
Sheet1.Paste Destination:=Worksheets("Sheet2").Cells(erow, 3)
End If
Next i
Application.CutCopyMode = False
Sheet2.Columns().AutoFit
Range("A1").Select
End Sub
'x1Up'应该是'xlUp'它应该是小写字母L不是1 –
谢谢Scott –