Apr 25 2022 11:29 AM
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 anyone know how to do this please?
Apr 25 2022 11:49 AM
I'd use SUMIF or SUMIFS formulas using the same conditions that determine the cell's color.
Apr 25 2022 12:01 PM
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 Sub
An alternative could be this code. You can click the button in cell F2 in the attached file to start the macro.