Sum value if another cell colour is (green / red)

nparsons75

Well-known Member
Joined
Sep 23, 2013
Messages
1,254
Office Version
  1. 2016
I would like to calculate the sum of values if their adjacent cell is a particular colour. Hope you can help....

In the example below, I would like to sum all values if the cell to the left is green, same for the reds.

Q3 Outlook TV.xlsx
FG
57g26,296
64g23,690
65g23,691
86r16,828
87r14,582
109g0
110g0
111g0
Wheelsets - Q3 JUL
Cells with Conditional Formatting
CellConditionCell FormatStop If True
F9:F160Cell Value="G"textNO
F9:F160Cell Value="A"textNO
F9:F160Cell Value="R"textNO
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
in the cells , conditional formatting seems to be if the cell contains a G or A or R

if so then you could use a SUMIF() using those codes in the range F9:F160

For a Green SUM = SUMIF(F9:F160, "G", G6:G160)

otherwise , am i misunderstanding
 
Upvote 0
Thats perfect and works great, I have however just realised I have missed something. The data is in a fliterable table, I need to be able to filter and the sumifs to also work as a subtotal when filtering. Is this possible?
 
Upvote 0
not sure where you applying the FILTER -
SUBTOTAL() will SUM a filtered list

=SUBTOTAL(109,G9:G160)
 
Upvote 0
So the filter is the drop down in a column. For example, column A includes a list of customers, I select the drop down filter and choose customer 1. I would like to see the sumifs work now for only the filtered selection, to do this I need to somehow combine the sumif and subtotal? I think....
 
Upvote 0
OK, So when you have the customer 1 , ther would be G , A & R and you want a SUM of each
I'm NOT sure , as that may need a sumproduct with offset
What version of Excel do you have ?
Add to your profile
 
Upvote 0
2016 I think.....maybe slightly later (work version), currently on 365 at home. I have read something about offset but blew my mind!
 
Upvote 0
This is a small example.....

When filtering on customer, the sum does not change

Book1
CDEFG
5sum
6customer 1r53217829
7customer 1r55
8customer 1r6689
9customer 2g415
10customer 2g266
11customer 2g6898
12customer 2a562
13customer 2a3336
14customer 3a2151
15customer 3g25
16customer 4g225
17customer 4a22265
Sheet1
Cell Formulas
RangeFormula
G6G6=SUMIFS(E6:E17,D6:D17,"g")
 
Upvote 0
=SUMPRODUCT(SUBTOTAL(3,OFFSET(F9:F160,ROW(F9:F160)-MIN(ROW(F9:F160)),,1)),(F9:F160="G")*(G9:G160))

IF you want to SUM all Visible , then you can use SUMPRODUCT()

BUT if you want G , R , A as separate SUMS

NOT 100% certain on this formula - MAY be worth closing this thread and starting a new one with the new question
based on this

Book1
EFGH
811
9Customer1g1
13Customer1A10000
16Customer1g10
Sheet1
Cell Formulas
RangeFormula
H8H8=SUMPRODUCT(SUBTOTAL(3,OFFSET(F9:F160,ROW(F9:F160)-MIN(ROW(F9:F160)),,1)),(F9:F160="G")*(G9:G160))
 
Last edited:
Upvote 0
Solution

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top