+ Reply to Thread
Results 1 to 21 of 21

How to calculate sums according to colours?

  1. #1
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    How to calculate sums according to colours?

    Hello

    I would like to be able to create the sums of all activities in red and all activities in blue (the original table is a lot larger).

    Thanks

    Daily Total
    Monday 00:30 00:50 00:50 00:50 03:00
    Tuesday 01:00 00:30 00:50 00:00 02:20
    Wednesday 00:30 00:30 00:00 00:00 01:00
    Thursday 00:30 00:30 00:30 00:00 01:30
    Friday 01:00 00:30 00:30 00:00 02:00
    Saturday 00:50 00:50 00:50 00:00 02:30
    Sunday 00:50 00:50 00:00 00:00 01:40

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: How to calculate sums according to colours?

    You can't without VBA. I am moving the thread accordingly.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to calculate sums according to colours?

    Please Login or Register  to view this content.
    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)



    Then use this formula, as shown in the sheet:
    =SumCellsByFontColor($B2:$F2,G$1)

    copied across and down. Format cells as [h]:mm. If you change the shadings, recalculate (Fn F9 on my laptop...)
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    Re: How to calculate sums according to colours?

    Hi

    Thanks for this, but I can't use VBA at work.

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to calculate sums according to colours?

    Then what you are asking for is impossible.... unless there are rules that govern which cells are coloured. If there are conditional formatting rules in use, the the same rule can be used for summing.

    So, how are the font colours assigned?

  6. #6
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    Re: How to calculate sums according to colours?

    Quote Originally Posted by Glenn Kennedy View Post
    Then what you are asking for is impossible.... unless there are rules that govern which cells are coloured. If there are conditional formatting rules in use, the the same rule can be used for summing.

    So, how are the font colours assigned?
    Hello

    Red means High
    Blue means Low

    Thanks

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to calculate sums according to colours?

    Can you use XLM functions rather than VBA?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  8. #8
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    Re: How to calculate sums according to colours?

    Quote Originally Posted by xlnitwit View Post
    Can you use XLM functions rather than VBA?
    Hello

    I should be able to work with simple macros.

    Thanks

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to calculate sums according to colours?

    Here is about the only way I know of, if you aren't using CF as Glenn mentioned earlier. It uses a defined name (CellColours) using the GET.CELL xlm function
    =GET.CELL(24,INDIRECT("Sheet1!RC",0))+NOW()*0
    in a mirror table on another sheet to return the font colour of each cell, and those are then used in the formulas. I borrowed Glenn's sample workbook for the layout.
    Attached Files Attached Files

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to calculate sums according to colours?

    And what makes a value high... and what makes a value low??

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to calculate sums according to colours?

    The formulae should have been sumif

    =SUMIF(Sheet2!$B2:$F2,3,$B2:$F2)

    and

    =SUMIF(Sheet2!$B2:$F2,23,$B2:$F2).

    You still have to fn F9, or equivalent, to refresh and you still have to save as a macro-enabled file. However, if you describes the RULES that underlie the whole thing... What makes this value high and that value low??? then it should be completely do-able.

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to calculate sums according to colours?

    Quite agree. Colour should be used to highlight value, not as a value.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: How to calculate sums according to colours?

    Quote Originally Posted by Nickitta View Post
    Hello

    I should be able to work with simple macros.

    Thanks
    To use macros, you need a macro-enabled workbook - maybe that is not allowed at work, either?

  14. #14
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    Re: How to calculate sums according to colours?

    Hello

    There aren't any rules. An activity is either "High Intensity" (Red) or "Light Intensity" (Blue). Needs to know the total of High and Low Intensity (Time spent on each, weekly and monthly).

  15. #15
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to calculate sums according to colours?

    It would solve all the problems if you added a row above each day where you could flag the intensity for each cell. You could then use straight SUMIF formulas for your totals, and use CF if you still need the cells coloured.

  16. #16
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to calculate sums according to colours?

    It strikes me that you are doing your best to make life REALLY complicated for yourself. So... you select a few cells, randomly (???), change their font colour and want the totals to be summed by colour without using macros. That can not be done.

    xlnitwit's suggestion, above, is your best chance of getting something workable.

  17. #17
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    Re: How to calculate sums according to colours?

    I am NOT making my life complicated, I've inherited that spreadsheet. The cells are not selected randomly. As explained previously Red means high and blue low?
    Last edited by AliGW; 10-25-2017 at 05:14 AM. Reason: Unnecessary quotation removed.

  18. #18
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to calculate sums according to colours?

    Well, I have provided you with what I believe to be about the only option to work with the layout you have, without VBA. However, I would strongly suggest that you change the layout if at all possible. It will make everything more robust and easier to report on.

  19. #19
    Registered User
    Join Date
    09-26-2017
    Location
    London
    MS-Off Ver
    2010
    Posts
    12

    Re: How to calculate sums according to colours?

    Quote Originally Posted by xlnitwit View Post
    Here is about the only way I know of, if you aren't using CF as Glenn mentioned earlier. It uses a defined name (CellColours) using the GET.CELL xlm function
    =GET.CELL(24,INDIRECT("Sheet1!RC",0))+NOW()*0
    in a mirror table on another sheet to return the font colour of each cell, and those are then used in the formulas. I borrowed Glenn's sample workbook for the layout.
    Thank you very much for your help, but I don't understand your formula. I think I need to ask the person in charge to rethink this Excel sheet.

  20. #20
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: How to calculate sums according to colours?

    Quote Originally Posted by Nickitta View Post
    I think I need to ask the person in charge to rethink this Excel sheet.
    I think that's a good idea! If they disagree, show them the alternative.

  21. #21
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to calculate sums according to colours?

    The point is HOW do you know WHICH cells need to be coloured red and which need to be coloured blue?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using time to calculate averages and sums
    By ckydmk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-21-2017, 11:28 AM
  2. Calculate sums based on date range
    By konbanwa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2017, 02:42 PM
  3. Calculate sums between two zeros
    By Jasper1908 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2015, 10:17 AM
  4. Formula to calculate different sums
    By nick2price in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-17-2013, 05:52 AM
  5. Calculate total sums from multiple text entries
    By pjfoster in forum Excel General
    Replies: 5
    Last Post: 01-29-2012, 08:11 PM
  6. Excel should calculate sums quicker in status bar
    By Phil K in forum Excel General
    Replies: 1
    Last Post: 06-03-2006, 03:15 PM
  7. excel does not calculate sums correctly
    By langholme in forum Excel General
    Replies: 2
    Last Post: 10-04-2005, 06:05 PM

Tags for this Thread

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