![]() |
Slow running code
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 |
Slow running code
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 -- Gary "Scott" wrote in message ... 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 |
All times are GMT +1. The time now is 05:46 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com