SOLVED

Sum cells with specific background color with filters?

%3CLINGO-SUB%20id%3D%22lingo-sub-3023059%22%20slang%3D%22en-US%22%3ESum%20cells%20with%20specific%20background%20color%20with%20filters%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3023059%22%20slang%3D%22en-US%22%3E%3CP%20class%3D%22%22%3EI%20came%20across%20an%20issue%20and%20couldn't%20find%20a%20proper%20solution%20on%20the%20internet%2C%20so%20if%20anyone%20could%20help%2C%20it%20would%20be%20greatly%20appreciated!%3C%2FP%3E%3CP%20class%3D%22%22%3EI%20have%20this%20type%20of%20data%20I'm%20working%20with%20at%20school%20(see%20Figure%201)%2C%20I%20need%20to%20count%20the%20sum%20of%20price%20values%20in%20columns%20B%20D%20F%20in%20each%20row%20separately%2C%20but%20only%20those%20that%20have%20a%20background%20color%20of%20either%20green%20or%20red%20(there%20is%20only%20one%20color%20in%20each%20row%2C%20there%20is%20no%20red%20and%20green%20in%20the%20same%20row).%20Basically%2C%20G2%20has%20to%20be%20the%20sum%20of%20B2%20D2%20F2%20with%20a%20filter%20that%20sums%20only%20green%2Fred%20cells%3B%20if%20it's%20green%2C%20fill%20the%20solution%20with%20green%20color%20as%20well%3B%20if%20red%20-%20with%20red%3B%20if%20there%20is%20no%20color%20-%20leave%20it%20blank.%20Then%20I%20will%20just%20drag%20it%20down%20to%20apply%20the%20same%20settings%20for%20the%20other%20rows.%20So%20the%20result%20should%20look%20like%20in%20Figure%202%20G%20column.%20Afterward%2C%20the%20%E2%84%96%20of%20the%20row%20has%20to%20be%20filled%20with%20the%20same%20color%20as%20the%20respective%20solution%20in%20the%20G%20column.%20In%20my%20case%20A2%20A3%20A6%20is%20filled%20with%20green%20and%20A4%20A7%20in%20red%3B%20if%20no%20color%20-%20don't%20fill%20with%20any%20color.%3C%2FP%3E%3CP%20class%3D%22%22%3EI%20hope%20I%20explained%20it%20well%20enough.%20Thanks%20in%20advance!%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%221.jpg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F330899iA06CDBEB7D655752%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%221.jpg%22%20alt%3D%221.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22%22%3EExcel%20version%3A%2016.55%20Excel%20for%20Mac%3C%2FP%3E%3CP%20class%3D%22%22%3EMacOS%20Catalina%2010.15.7%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3023059%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3023219%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20cells%20with%20specific%20background%20color%20with%20filters%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3023219%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1235080%22%20target%3D%22_blank%22%3E%40edd21475%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%20what%20you%20are%20looking%20for%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColor%20in%20range%20B2%3AF7%20is%20entered%20manually%20and%20color%20in%20range%20A2%3AA7%20is%20done%20by%20conditional%20formatting.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3023247%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20cells%20with%20specific%20background%20color%20with%20filters%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3023247%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1235080%22%20target%3D%22_blank%22%3E%40edd21475%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20this%20what%20you%20are%20looking%20for%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColor%20in%20range%20B2%3AF7%20has%20to%20be%20entered%20manually%20and%20color%20in%20range%20A2%3AA7%20is%20done%20by%20conditional%20formatting.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I came across an issue and couldn't find a proper solution on the internet, so if anyone could help, it would be greatly appreciated!

I have this type of data I'm working with at school (see Figure 1), I need to count the sum of price values in columns B D F in each row separately, but only those that have a background color of either green or red (there is only one color in each row, there is no red and green in the same row). Basically, G2 has to be the sum of B2 D2 F2 with a filter that sums only green/red cells; if it's green, fill the solution with green color as well; if red - with red; if there is no color - leave it blank. Then I will just drag it down to apply the same settings for the other rows. So the result should look like in Figure 2 G column. Afterward, the № of the row has to be filled with the same color as the respective solution in the G column. In my case A2 A3 A6 is filled with green and A4 A7 in red; if no color - don't fill with any color.

I hope I explained it well enough. Thanks in advance!

1.jpg

 

Excel version: 16.55 Excel for Mac

MacOS Catalina 10.15.7

5 Replies
best response confirmed by edd21475 (New Contributor)
Solution

@edd21475 

Is this what you are looking for?

 

Color in range B2:F7 has to be entered manually and color in range A2:A7 is done by conditional formatting.

Yes, this is pretty much what i need, thank you so much!

@edd21475 

Glad it helped. I just noticed that you want to conditionally format both columns A and G. See attached file sheet "Tabelle2".

@Quadruple_Pawn 

 

I have figured out the condition formating, thank you for the reply! However, i got one more questing, maybe you could help? 

In the example you provided, the VBA doesnt update the color index if i change the color of the respective cell, i have to manually reapply the formula so the color index changes. Is there a way to make it update automatically once i change the color of the cell?

Eg.: If i change B2 to green, the index in B9 doesnt update, i will have to refresh it manually. So what i would like is once i change B2 to green, B9 automatically refreshes from 3 to 50

 

Looking forward to your reply!

@edd21475 

When i open the spreadsheet i have to allow macros and then i can select for example cell C4 which has green color (in sheet Tabelle2). Then i copy the format of cell C4 and paste this format in cell B2. After this cell B9 automatically updates to 50 and cells A2 and G2 automatically are formatted in green color.