I want to color the data in my excel sheets:
I need to look at each row separately, and color the cells with equal data value the same color.
The below code iterates all data in first 10 rows and colors each cell differently. I'm not sure how to remember the colored cells and their colors along the way, and apply that color instead of the new color if the current cell is remembered in a list already for this row.
Is there something that could be used as a dynamic list in vba, and how?
Sub Test1()
Dim x As Integer, rowInt As Integer, color As Integer
Application.ScreenUpdating = False
For rowInt = 1 To 10
color = 3
'numRows = number of cells before the first blank cell in the row ("A" & rowInt)
numRows = Range("A" & rowInt, Range("A" & rowInt).End(xlToRight)).Columns.Count
If numRows >= 16384 Then
numRows = 1
End If
Range("A" & rowInt).Select
For x = 1 To numRows
With Selection.Interior
.ColorIndex = color
.Pattern = xlSolid
End With
color = color + 1
ActiveCell.Offset(0, 1).Select
Next
Next
Application.ScreenUpdating = True
End Sub