+ Reply to Thread
Results 1 to 11 of 11

How do I sum up values only in cells that are color filled?

  1. #1
    Registered User
    Join Date
    05-01-2008
    Posts
    7

    How do I sum up values only in cells that are color filled?

    This thing drives me crazy for the past few days. Please helpI can go to sleep.
    I have several columns with numerical data. When certain criteria are met, a person manually makes some of the column fields a green fill color via the color fill button.

    Let's say I have data in cells E4 to E14
    Below, I have a total field (auto Sum function used to total all),
    And, another row with The Colored Green totals.
    How do I enter the appropriate code to total only the fields that are green??
    I have found some info on verious sites but I have been unsuccesful to implement.
    (http://www.cpearson.com/excel/colors.aspx)
    I attach a sample sheet, I was playing around a bit, you can ignore the fill color red, just deal with the green fields.

    Thank you in advance for any of your help.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See attached examples from these sites

    http://xldynamic.com/source/xld.ColourCounter.html#code

    http://www.ozgrid.com/Excel/count-sum-cell-color.htm

    http://www.exceltip.com/st/Sum_by_co...Excel/517.html

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    05-01-2008
    Posts
    7

    Still can't get it work, can you please download my sample sheet and provide the code

    Thank you for your links, I tried the 3rd one, just copied and pasted the code, changed the ranges etc, but can't get it work.
    I appreciate your help, if it is not too time consuming it would be great if you opened my sample sheet and provided the code to total one of the green columns so I can see 1st hand. Thank you!!! you will really take my headache away.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    I opened your example and have replied with 3 working examples on the attachment I uploaded

    VBA Noob

  5. #5
    Registered User
    Join Date
    05-01-2008
    Posts
    7

    90% there, VBA Noob thanks a million!!! here is a small problem

    Thanks so much VBA Noob.. I think I can rest 90% now. Here is the 10%.
    Is there a way to automatically update the totals, if I go back after the function entry and make another field green?
    When I change a new field in an old column the sub-total does not update unless I click on the field and press return. Can the update happen automatically when I make a new field green?
    Thanks so much!!

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try a full recalc.

    Ctrl + Alt + F9

    or take a look at
    Please Login or Register  to view this content.
    Note Volatile may slow down the spreadsheet (see link for more)

    http://www.decisionmodels.com/calcsecretsj.htm

    VBA Noob

  7. #7
    Registered User
    Join Date
    05-01-2008
    Posts
    7

    What is the correct procedure to enter the application.volatile code?

    Thanks again VBA Noob.
    What is the correct procedure to enter the application.volatile code?
    I appreciate your help, you really made my day!

  8. #8
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Again example on link..

    Usual goes on the second line like

    Please Login or Register  to view this content.
    It will slow the spreadsheet down. I would set a macro to do the recalc

    Please Login or Register  to view this content.
    VBA Noob

  9. #9
    Registered User
    Join Date
    05-01-2008
    Posts
    7

    Final question

    Thanks VBA Noob, I ended up using an extra "update" button with a macro attached to update fields, this will work.
    Q. Did you enter the extra modules in my original excel sheet attached, or, were they added by me while experimenting (going crazy), to make this work?
    Or, did you just add the fomula's in the subtotal fields?
    I think in one of my tries, when I deleted the extra modules in the excel sheet, even with your formula's in the subtotal fields, I got the ?NAME in the subtotal, so I left them alone.
    THANKS AGAIN FOR YOUR SUPPORT, YOU ARE ABSOLUTELY AWSOME!!! Your gesture and quick help makes this world be a better place.

  10. #10
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi 1959USA,

    I added extra modules and the formulas for each module

    So below are the modules, function and Formula they relate too.

    As you found if you delete the module the formula will return the Name error

    Module1
    Please Login or Register  to view this content.
    =ColorFunction($A$13,B3:B11,TRUE)
    Cell B13

    Module2
    Please Login or Register  to view this content.
    =ColorFunction($A$13,B3:B11,TRUE)
    Cell B15


    Module3
    Please Login or Register  to view this content.
    =SUMPRODUCT(--(ColorIndex(B3:B11)=4),B3:B11)
    Cell B17

    HTH

    VBA Noob

  11. #11
    Registered User
    Join Date
    05-01-2008
    Posts
    7

    Smile Thanks!

    Thanks for everything! Best Wishes, John

+ 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