Results 1 to 3 of 3

Thread: Adding values based on cell colour

  1. #1

    Adding values based on cell colour



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    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

  3. #3
    any doubts .. please send me the attachment i will help u

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •