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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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