删除重复值时Excel VBA错误。 运行时出错,而不是逐步执行

当碰到Run Sub(F5)时,运行这个子程序时,出现“运行时错误”1004:“应用程序定义的错误或对象定义的错误”。 但是,当我使用debuggingfunction(F8)通过它,它通过这条线没有错误。 有什么我可以改变代码来纠正这一点。 代码如下:

lastrow = Sheet9.Cells(Rows.count, 1).End(xlUp).Row Range(Sheet9.Cells(1, 1), Sheet9.Cells(lastrow, 14)).Clear lastrow = Sheet3.Cells(Rows.count, ProjCol).End(xlUp).Row For i = 1 To lastrow Sheet3.Range(Sheet3.Cells(i + 1, ProjCol), Sheet3.Cells(i + 1, LampCol)).Copy Destination:=Sheet9.Range(Sheet9.Cells(i, 1), Sheet9.Cells(i, 2)) Next i lastrow2 = Sheet9.Cells(Rows.count, 1).End(xlUp).Row 'ERROR OCCURS WITH LINE BELOW Sheet9.Range(Cells(1, 1), Cells(lastrow2, 2)).RemoveDuplicates Columns:=Array(1, 2), Header:=xlNo