Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Mar 2001
    Location
    Indiana, USA
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conditional Sum with Color (XL2000)

    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?

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Sum with Color (XL2000)

    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:

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


    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.
    Legare Coleman

  3. #3
    Super Moderator WebGenii's Avatar
    Join Date
    Jan 2001
    Location
    Redcliff, Alberta, Canada
    Posts
    4,066
    Thanks
    2
    Thanked 5 Times in 5 Posts

    Re: Conditional Sum with Color (XL2000)

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

    Cheers
    [b]Catharine Richardson (WebGenii)
    WebGenii Home Page
    Moderator: Spreadsheets, Other MS Apps, Presentation Apps, Visual Basic for Apps, Windows Mobile

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conditional Sum with Color (XL2000)

    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

    Edited Mar 13th 2004 to update link
    Attached Files Attached Files
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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