I wrote the following semi-successful code which returns duplicate records. One problem - it is SO S---L---O---W - I mean, really SLOW, it takes like a few hours to complete the check. There's got to be a better way. Can anyone offer any advice?
It uses nested loops to check each row against every other row in a very very large spreadsheet, no less than 15000 rows.
Ah say, there's somethin' a little "eeeeeeee" 'bout a boy who don't like basbawl...
It uses nested loops to check each row against every other row in a very very large spreadsheet, no less than 15000 rows.
Code:
Dim DupCount As Integer
Dim RowCount, LastRow As Integer
Dim NextWholeRow As String, CurrentWholeRow As String
Dim CurrentCell As Range, NextCell As Range
Set CurrentCell = ActiveSheet.Range("c18")
RowCount = 1
Do Until CurrentCell.Row = 20000
Do Until RowCount = 20000
Set NextCell = CurrentCell.Offset(RowCount, 0)
CurrentWholeRow = CurrentCell.Value & CurrentCell.Offset(0, 1) & CurrentCell.Offset(0, 3) & FixOverflow(CurrentCell.Offset(0, 7)) & CurrentCell.Offset(0, 11)
NextWholeRow = NextCell.Value & NextCell.Offset(0, 1) & NextCell.Offset(0, 3) & FixOverflow(NextCell.Offset(0, 7)) & NextCell.Offset(0, 11)
If CurrentWholeRow <> "x" Then
If NextWholeRow = CurrentWholeRow Then
MsgBox "I found a duplicate"
DupCount = DupCount + 1
End If
End If
RowCount = RowCount + 1
Loop
Set NextCell = CurrentCell.Offset(1, 0)
Set CurrentCell = NextCell
RowCount = 1
' CurrentCell = CurrentCell.Offset(1, 0)
Loop
MsgBox DupCount & " Duplicates found"
Ah say, there's somethin' a little "eeeeeeee" 'bout a boy who don't like basbawl...