I have a Spreadsheet that i would like to be able to carry out a sum of Range of cells that are equal to a certain colour and also contain no text/numbers. I have come across some code that has created a Function that works perfect for summing the cells of a certain colour. I now need to modify it to also make sure it excluded cells that have text/numbers in them.
This below is what i found online and have used so far.
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)
Dim rCell As Range
Dim lCol As Long
Dim vResult
lCol = rColor.Interior.ColorIndex
If SUM = True Then
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = WorksheetFunction.SUM(rCell, vResult)
End If
Next rCell
Else
For Each rCell In rRange
If rCell.Interior.ColorIndex = lCol Then
vResult = 1 + vResult
End If
Next rCell
End If
ColorFunction = vResult
End Function
Bookmarks