Forum Discussion
KBmentions
Apr 25, 2022Copper Contributor
adding up numbers of colours in a column
Please can someone help. I have coding which determines a colour in a column dependant on a figure. I want to add up all the reds in the column and all the greens in the same column. Does anyo...
OliverScheurich
Apr 25, 2022Gold Contributor
Sub add()
Dim i As Integer
Dim j As Integer
For i = 3 To 17
If Cells(i, 3).Interior.ColorIndex = 4 Or Cells(i, 3).Interior.ColorIndex = 3 Then
j = Cells(i, 3).Value + j
Else
End If
Next i
Cells(1, 1).Value = j
End SubAn alternative could be this code. You can click the button in cell F2 in the attached file to start the macro.