Adding values based on cell colour

Stewie

New member
Joined
Aug 6, 2012
Messages
7
Reaction score
0
Points
0
Hi, I am trying to calculate value of cells with a specific colour - red.


I understand excel uses vba for this function - can you advise please, i have no experience of using code,


Regards,
Stewie
 
Hi

Please use below UDF
based on cells..
Function ColorFunction(rColor As Range, rRange As Range, Optional SUM As Boolean)


Application.Volatile
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
 
any doubts .. please send me the attachment i will help u
 
Back
Top