+ Reply to Thread
Results 1 to 11 of 11

Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

  1. #1
    Registered User
    Join Date
    04-06-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    5

    Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    Hi,

    I am purely guessing that the solution will need a VBA script, hence me posting here.

    I have a formula that summarizes planed driven km in a set of specific countries.
    I have a second formula that uses TEXTJOIN to list the calendar weeks each country is planned.

    To get an idea (sample attached below):
    SampleKMCW.PNG

    In B3 I use this code:
    Please Login or Register  to view this content.
    In C3 I use this code:
    Please Login or Register  to view this content.
    As it it works now it summarizes everything and disregarding color. I need to incorporate the ability to only summarize the "Blue" ones (both KM and CW's) and optimally, if it is possible, to toggle between "Blue" and "Green" (from referenced color cell).

    If we take DK for example, and the result I would like to get:
    DK: 500 KM (CW14) -- Blue cells
    DK: 200 KM (CW12; CW13) -- Green cells


    Can this be done?
    Or do you have any other solutions to this problem?
    Attached Files Attached Files
    Last edited by lixxy; 09-21-2023 at 04:32 AM.

  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,853

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    Welcome to the forum.

    What makes the cells blue or green? Colour and other formatting cannot be used by a formula - sorry.
    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,053

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    Is there a logical RULE that determines whether a cell is colured green/bue?
    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
    04-06-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    5

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    Currently the color in Table A and B are applied manually.
    Eventually I want to reach a goal where Table B takes the same colors as Table A automatically. But that is not a priority for me at this time.
    Getting the summary correct is higher focus.

    I've seen VBA scripts that creates a function that could SUM by color, though they do not cover my needs.

  5. #5
    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,853

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    Well, it's going to have to be VBA, I am afraid.

  6. #6
    Registered User
    Join Date
    04-06-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    5

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    I found this VBA online:

    Please Login or Register  to view this content.
    Though I have not found a way to incorporate it into the existing formula or to modify it to sum based on a country in Table A and summarize the corresponding cells in Table B.

  7. #7
    Registered User
    Join Date
    04-06-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    5

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    How about this then,

    I create a third table (C), which is populated with GET.CELL to get the cell color from Table A.
    I have another GET.CELL next to the color reference (VAL).

    Is it now possible to incorporate into the existing formula that only the cells "37" from Table C is to be used?

  8. #8
    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,053

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    Is this what you'd intended. It's hard to tell, as you edited the first thread after replies were recieved (better to make changes in the thread...).


    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    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,053

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    And for the code (which I just noticed also changes!!):
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 09-21-2023 at 05:35 AM.

  10. #10
    Registered User
    Join Date
    04-06-2019
    Location
    Sweden
    MS-Off Ver
    365
    Posts
    5

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    My apologies, thought it would be confusing with different versions.

    But yes, it now works as I had hoped. Thank you very much!

  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,053

    Re: Incorporate SUM by cell color in a formula with HSTACK, MAP and LAMBDA.

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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. Replies: 14
    Last Post: 09-21-2023, 12:22 AM
  2. [SOLVED] Lambda to count specific cell colors in a range
    By jaryszek in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-22-2022, 11:37 AM
  3. Replies: 2
    Last Post: 10-11-2021, 08:58 AM
  4. how to convert a VLOOKUP & INDIRECT formula to a LAMBDA function
    By jrtaylor in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-13-2021, 05:11 PM
  5. [SOLVED] VBA Worksheet change - incorporate cell with formula
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-26-2016, 01:31 PM
  6. Replies: 2
    Last Post: 01-29-2015, 12:39 PM
  7. Incorporate Adjacent Cell in Formula w/o Naming Cell Address?
    By cyberphonics in forum Excel General
    Replies: 9
    Last Post: 10-04-2009, 10:28 AM

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