• Conditional Sum with Color (XL2000)

    Author
    Topic
    #365613

    Someone I work with wants to sum a range of cells only if the fill color is blue. Is there a way to create a formula that will do this? I have already created a VBA solution for him, but he is dead set on using a worksheet formula. Can it be done? I was trying to use the SUMIF formula, but couldn’t find a way to use a colorindex as the conditional criteria. Is it possible?

    Viewing 2 reply threads
    Author
    Replies
    • #564737

      There is no way to get the ColorIndex of a cell without using VBA. You could use a User Defined Function like the one below in a SumIf:

      Public Function getcolorNum(oCell As Range) As Long
          Application.Volatile
          getcolorNum = oCell.Interior.ColorIndex
      End Function
      

      Unfortunately, Excel does not recognize a color change and a recalculate event, so if the only change is the color the formula is not going to recalculate.

    • #564991

      What about using the condition that the colour change is based on?

      Cheers

    • #565050

      It can be done. But it involves quite some wizardry in XL!

      Check out the sample spreadsheet I attached. Based upon my file Arg2Name.zip from

      http://www.bmsltd.ie/mvp%5B/url%5D

      Edited Mar 13th 2004 to update link

    Viewing 2 reply threads
    Reply To: Conditional Sum with Color (XL2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: