Excessive time to run macro

okeefe1961

New Member
Joined
Aug 21, 2008
Messages
3
I have a file 64,00 rows by 109 columns ~ 4M in size, that contains multiple duplicate entries (~19,000 unique entries). I have the following macro to remove the duplicates but it takes in excess of 2 hours to run. Any idea's on why it is so slow / and or ways to improve its speed. I don't think its my machine

Core2 Duo @2.4GHz - 4G Ram
Windows XP Pro SP3
Excel 2007


Code:
Sub DelDupsRows()
Dim iListCount As Long, iCtr As Long
Dim cstr1 As String, Last_Audit_Sheet As String
Dim Source As Worksheet, start As Date, Finish As Date

start = Time

Set Source = Worksheets("Tmp_Audit_Trail")

' Turn off screen updating to speed up macro.
Application.ScreenUpdating = False

' Get count of records to search through.
iListCount = Range("A1048576").End(xlUp).Row

For iCtr = iListCount To 3 Step -1
   If Source.Cells(iCtr, 1).Value = Source.Cells(iCtr - 1, 1).Value Then
     Rows(iCtr & ":" & iCtr).Delete Shift:=xlUp
   End If
Next iCtr

Application.ScreenUpdating = True
Finish = Time
MsgBox "Done! Start- " & start & "  Finish- " & Finish

End Sub
 
Last edited by a moderator:

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Why not try using Data>Advanced filter...? That has an option to only return unique values.

Though I don't know where that option will be in 2007, which you appear to be using.:)
 
Upvote 0
Advance Filter is on the Data Ribon under the Sort & Filter Section.

Hope that helps.
 
Last edited by a moderator:
Upvote 0
If you really don't want to use filters, try turning off automatic calculations.
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top