Dazzawm
Well-known Member
- Joined
- Jan 24, 2011
- Messages
- 3,748
- Office Version
- 365
- Platform
- Windows
I have the code below that when data matches in C then it colours the row then does the same again on next rows in C and so on then starts again with the colouring. Could the colours be changed please as some are too bright on some. So instead of the vb array what needs changing so it uses .Interior.ColorIndex = 3 or 6 for example on each colour? Thanks
Code:
Sub ColourTheRows()
' This colours in the rows that have the same value in column c
Application.ScreenUpdating = False
Dim colors As Variant, SameData As String, i As Long, j As Integer
colors = Array(vbRed, vbGreen, vbYellow, vbBlue, vbWhite, vbMagenta, vbCyan)
SameData = Cells(1, 3)
For i = 1 To Cells(Rows.Count, 3).End(xlUp).Row
If Cells(i, 3) <> SameData Then
j = j + 1
SameData = Cells(i, 3)
End If
If j = 7 Then
j = 0
End If
Rows(i).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = colors(j)
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Next i
Application.ScreenUpdating = True
End Sub