NicholasP
Active Member
- Joined
- Nov 18, 2006
- Messages
- 291
I have a macro that takes ~22 seconds to run and ~18 of those seconds are in this piece of code:
This is a pretty small file and I tried deleting all the rows beneath the used area (<200 used rows) as well as unused columns, thinking there may have been some formatting that was forcing Excel to slow down.
I also tried setting calculations to xlmanual, though that only saved ~3 seconds on the overall macro. Specifically, the code really bogs down when a row is deleted. I tried only deleting the necessary cells, but that actually made the code run slower. I'm out of ideas here and any help would be greatly appreciated.
Thanks
Nick
Code:
For A = x To Z Step -1
If Cells(A, 3) = "" And Cells(A, 4) = "" And Cells(A, 5) = "" And Cells(A, 6) = "" And Cells(A, 7) = "" And Cells(A, 8) = "" And Cells(A, 9) = "" And Cells(A, 10) = "" And Cells(A, 11) = "" And Cells(A, 12) = "" And Cells(A, 13) = "" And Cells(A, 14) = "" Then
If Cells(A, 2) <> "" And Cells(A, 1) <> "" And Cells(A, 2) <> "M" And Cells(A, 1) <> "ABCD" And Cells(A, 2) <> "I" And Cells(A, 1) <> "IPR" And Cells(A, 1) <> "Total" Then
Cells(A, 3).EntireRow.Delete Shift:=xlUp
End If
End If
Next
This is a pretty small file and I tried deleting all the rows beneath the used area (<200 used rows) as well as unused columns, thinking there may have been some formatting that was forcing Excel to slow down.
I also tried setting calculations to xlmanual, though that only saved ~3 seconds on the overall macro. Specifically, the code really bogs down when a row is deleted. I tried only deleting the necessary cells, but that actually made the code run slower. I'm out of ideas here and any help would be greatly appreciated.
Thanks
Nick
Last edited: