+ Reply to Thread
Results 1 to 7 of 7

Conditional sum based on number color

  1. #1
    Registered User
    Join Date
    02-13-2011
    Location
    Conway, AR
    MS-Off Ver
    Excel 2003
    Posts
    2

    Conditional sum based on number color

    I have a column for which I want to sum the numbers. The numbers start out as all red. As I change the numbers to black, then I want that number to be added to the total. At various times I will have a mixture of red and black numbers. I only want the black numbers to total.
    Last edited by jimisom; 02-14-2011 at 09:06 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Conditional sum based on number color

    This tutorial should give you an idea or two on how to accomplish your end result.
    http://www.datapigtechnologies.com/f...rtonColor.html

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional sum based on number color

    Hi jimisom

    I've used this Function with success http://www.ozgrid.com/VBA/sum-count-cells-by-color.htm
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Conditional sum based on number color

    Hi jimisom

    you could use a UDF
    red= 3 and black=1

    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Conditional sum based on number color

    On this subject I would just restate the point made in the OzGrid reference, namely:

    Quote Originally Posted by OzGrid
    Be aware that the changing of a cells fill color will not cause the Custom Function to recalculate, even if you press F9 (Recalculates the whole Workbook). You will need to either, select the cell and re-enter the formula, or go to Edit>Replace and replace = with =, or use Ctrl+Alt+F9

    Try also to avoid the use of Application.Volatile as it will not help in this case and only slow down Excel's calculation time.
    In short, this approach is fundamentally flawed.
    You are in essence:

    a) building into your model the potential for calculation errors.

    b) using UDF rather than native functions - generally slower

    c) introducing calculation overhead via Application.Volatile (worse given point 2)

    Given the above facts differentiation / calculation based on manual formatting should be avoided at all times.

    Quote Originally Posted by jimisom
    The numbers start out as all red. As I change the numbers to black, then I want that number to be added to the total.
    You should be using adjacent to cells to denote a marker for inclusion/exclusion, at which point use the markers to:

    a) act as source for Conditional Formatting rules - to determine fill colour of number cells

    b) act as basis for SUM calculations (ie SUMIF)

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Conditional sum based on number color

    Point well taken DO.

  7. #7
    Registered User
    Join Date
    02-13-2011
    Location
    Conway, AR
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Conditional sum based on number color

    Thanks everyone. If your post didn't solve my problem directly, they all gave me great insight as to the various capabilities of Xcel. Every post gave me a clue as to how to solve other problems. I hope I "scaled" each post because you were all very helpful. Thanks again. Jim

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1