Forum Discussion
dickcarey460gmailcom
Feb 28, 2023Copper Contributor
use sumif function when criteria is cell hihlighted with a color highlight
I want to use sumif function to add a column of numbers when criteria is a fill color in the cells. How do I do this.
Chuks1890
Jul 17, 2023Copper Contributor
HansVogelaar
Jul 17, 2023MVP
Thanks. See the attached demo workbook. The function used is
Function SumIfColour(SumRange As Range, CriteriaRange As Range, Criteria As Variant, _
ColourRange As Range, ColourCell As Range) As Double
Dim i As Long
Dim r As Double
For i = 1 To SumRange.Count
If CriteriaRange(i).Value = Criteria And ColourRange(i).Interior.Color = _
ColourCell.Interior.Color Then
r = r + Val(SumRange(i).Value)
End If
Next i
SumIfColour = r
End Function
- Chuks1890Jul 17, 2023Copper ContributorThanks.
One more, How can i use SumifsColour(- HansVogelaarJul 17, 2023MVP
Once again, please provide an example of what you want to do.
- RLAJackJul 01, 2024Copper Contributor
I was wondering how to do the same thing e.g. sum the numbers in column D which are in rows with blue highlighted cells. Or even better sum all the numbers in blue highlighted cells
I tried your formula but may have chosen the wrong cells.