I'm facing a problem with one of the macros I've written to compare the rows in a sheet and highlight the duplicates if any. But, it is taking longer time to complete it's operation when there are more number of records. When the comparision starts, it picks up the first record, compares it with all the remaining records and highlight if there is a duplicate and then moves on to the second record and this process continues till the last record.
Can anybody tell me a better solution for this?
Here is my code;
RowCount = ActiveSheet.UsedRange.Rows.Count
ColumnCount = ActiveSheet.UsedRange.Columns.Count
For frownum = 1 To RowCount
For rownum = 1 To RowCount
RecFound = 0
For colnum = 1 To ColumnCount
If frownum <> rownum Then
If ActiveSheet.Cells(frownum, colnum).Value = ActiveSheet.Cells (rownum, colnum).Value Then
RecFound = RecFound + 1
End If
End If
Next colnum
If ColumnCount = RecFound Then
For errRow = 1 To ColumnCount
ThisWorkbook.Worksheets("RowCompare").Cells(frownum, errRow).Interior.Color = RGB(251, 231, 128)
Next errRow
End If
Next rownum
Next frownum