Excel VBA Duplication Check on 250,000 rows

johnbird1988

Board Regular
Joined
Oct 6, 2009
Messages
199
Hello,

I am trying to preform a duplicate row check on a data set spanning over 6 columns and approx. 250,000 rows of data.

What I am trying to find is the more efficient way to highlight any duplicate rows. The code I have at the moment currently take around 45 minutes plus and I can’t help think there is a more efficient way.

I have added below an extract of my current code for the duplicate check. In column G I have added a concatenated for A:F. This column is then removed at the end of the code.

Code:
For Each w In .Range("G2:G" & iRow)
If Application.CountIf(.Range("G2:G" & iRow), w.value) > 1 Then
w.Interior.Color = RGB(255, 199, 206)
w.Font.Color = RGB(156, 0, 6)
End If
Next w

Any help would be great thank you,

John
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Hello,

after reading fora few seconds my immpression is, the code calculates 250,000 ^2 times.

Why not write the "countif" - formula once in the top row and use dopple-click (autofill)) for all 250,000 rows. Then either an autofilter for ">1" or a Range.Find should identify the duplicates.

regards
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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