Slow running code

S

Scott

I am trying to delete or clear out duplicate rows based on a few cells that
match. The cells other than those in the B, C & M columns may not match.
The below code works but runs very slowly (takes about 5 seconds per row).
Anyone know of a better (faster) way?

For RowIndex = 2 To 2000
If Range("B" + CStr(RowIndex)) = Range("B" + CStr(RowIndex + 1)) And _
Range("C" + CStr(RowIndex)) = Range("C" + CStr(RowIndex + 1)) And _
Range("M" + CStr(RowIndex)) = Range("M" + CStr(RowIndex + 1)) Then
Range("A" + CStr(RowIndex) + ":" + "Z" + CStr(RowIndex)) = ""
End If
Next
 
G

Gary Keramidas

turn off calculation and screenupdating before the code and then turn it back on
after it runs

With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With

' your code


With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top