most
Board Regular
- Joined
- Feb 22, 2011
- Messages
- 107
- Office Version
- 365
- 2019
- Platform
- Windows
- Mobile
I know color code duplicates is a very common issue here on the internet, but I can't find any solution which is similar to my needs.
Based on the value in column A("My data") I want to color code the whole row where the value is the same.
I.e. row 1 and 2 has the same value and should be colored to grey. Row 3, 4 and 5 has the same value and should be colored to a another color and so on.
[TABLE="width: 220"]
<tbody>[TR]
[TD]My data[/TD]
[TD](entire row color)[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]30[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]30[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]40[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]40[/TD]
[TD]Dark grey[/TD]
[/TR]
</tbody>[/TABLE]
This is my code for the moment, but it doesn't work. The second if statement is major wrong.
Based on the value in column A("My data") I want to color code the whole row where the value is the same.
I.e. row 1 and 2 has the same value and should be colored to grey. Row 3, 4 and 5 has the same value and should be colored to a another color and so on.
[TABLE="width: 220"]
<tbody>[TR]
[TD]My data[/TD]
[TD](entire row color)[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]30[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]30[/TD]
[TD]Grey[/TD]
[/TR]
[TR]
[TD]40[/TD]
[TD]Dark grey[/TD]
[/TR]
[TR]
[TD]40[/TD]
[TD]Dark grey[/TD]
[/TR]
</tbody>[/TABLE]
This is my code for the moment, but it doesn't work. The second if statement is major wrong.
Code:
LastRow = Cells(Rows.count, 1).End(xlUp).rowrowcolor = 225
For Each c In Range("A2:A" & LastRow)
If c.Offset(1, 0).Value = c.Value Then
Rows(c.row).EntireRow.Interior.Color = RGB(205, rowcolor, 205)
Rows(c.row + 1).EntireRow.Interior.Color = RGB(205, rowcolor, 205)
End If
If rowcolor = 225 Then
rowcolor = 255
Else
rowcolor = 225
End If
Next c