Lovelylou79
New Member
- Joined
- Sep 4, 2017
- Messages
- 37
Hi All,
I've come to the end part of a wee project and am a little stuck. I need to compare the data in two rows and highlight both if the entire rows, with the exception of coloumn "A" are duplicates.
The code will activate if "A" has a value. That then becomes the source row, checking the row directly beneath. Once those 2 rows are compared, the code will find the next "A" with data, compare 2 rows only, then continue to lastrow.
I've begun the code by concatenating active row cells B to N for comparison and am now stuck on the For, If, then for highlighting the duplicates. My code is a bit of a mess and doesnt work at all, but I think I'm on the right track. Any help would be greatly appreciated...
I've come to the end part of a wee project and am a little stuck. I need to compare the data in two rows and highlight both if the entire rows, with the exception of coloumn "A" are duplicates.
The code will activate if "A" has a value. That then becomes the source row, checking the row directly beneath. Once those 2 rows are compared, the code will find the next "A" with data, compare 2 rows only, then continue to lastrow.
I've begun the code by concatenating active row cells B to N for comparison and am now stuck on the For, If, then for highlighting the duplicates. My code is a bit of a mess and doesnt work at all, but I think I'm on the right track. Any help would be greatly appreciated...
Code:
Dim i As IntegerDim lr As Integer
lr = ActiveSheet.Range("B" & Rows.Count).End(xlUp).Row
Range("N2:N" & lr).Formula = "=CONCATENATE(RC[-12]&RC[-11]&RC[-10]&RC[-9]&RC[-8]&RC[-7]&RC[-6]&RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1])"
Set rng1 = Cells(i).Offset(0, 13)
Set rng2 = Cells(i).Offset(1, 13)
For i = 2 To lr
If Cells(i, 1) = "" Then
i = i + 1
Else
If rng1 = rng2 Then
rng1.EntireRow.Interior.ColorIndex = 15
rng2.EntireRow.Interior.ColorIndex = 15
End If
Next i