RGB values as criteria in SUBTOTAL or Aggregate count.

vanwooten

New Member
Joined
Dec 15, 2020
Messages
43
Office Version
  1. 365
Platform
  1. Windows
The attached image shows a color key at the top of column X. I have a function that returns the color key RGB values to the left of it. The table column below the key (Trade Notes) has these colors throughout and I have a table column (Color) that displays the RGB values for those colors. I am try to figure out a formula using SUBTOTAL or AGGREGATE to produce those percent values in column W next to the key. so W3 = count of yellows displayed in table / count of all rows being displayed in table.
 

Attachments

  • 2022-09-11 (3).png
    2022-09-11 (3).png
    35.1 KB · Views: 15

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
It would have to be SUBTOTAL for what you're asking, AGGREGATE does not work correctly if you try to combine conditional criteria with filter / hidden row exclusions.

While I would expect it to be possible, as it is going to be utilising an existing UDF we would need the underlying code in order to be able to test any ideas.

Assuming that your function is named RGB, the theory would be something like
Excel Formula:
=SUMPRODUCT((SUBTOTAL(9,OFFSET($W$9,ROW($W$9:$W$1000)-ROW($W$9),0,1,1)=1)*(RGB($X$9:$X$1000)=V2))
Unlikely that it will be the correct formula but it is the best that I can do without testing.

The lower part of the image is appears to be a structured table e.g. one that uses references like Table1[@Profit%]. If it is then it would be better to use the names in the formula rather than cell ranges. On a side note, the colour banding on a table works differently to normal cell formatting so it is possible that your function will not recognise those cells correctly. As with the formula, this is an unknown factor without the function code for testing.
 
Upvote 0
Solution
It would have to be SUBTOTAL for what you're asking, AGGREGATE does not work correctly if you try to combine conditional criteria with filter / hidden row exclusions.

While I would expect it to be possible, as it is going to be utilising an existing UDF we would need the underlying code in order to be able to test any ideas.

Assuming that your function is named RGB, the theory would be something like
Excel Formula:
=SUMPRODUCT((SUBTOTAL(9,OFFSET($W$9,ROW($W$9:$W$1000)-ROW($W$9),0,1,1)=1)*(RGB($X$9:$X$1000)=V2))
Unlikely that it will be the correct formula but it is the best that I can do without testing.

The lower part of the image is appears to be a structured table e.g. one that uses references like Table1[@Profit%]. If it is then it would be better to use the names in the formula rather than cell ranges. On a side note, the colour banding on a table works differently to normal cell formatting so it is possible that your function will not recognise those cells correctly. As with the formula, this is an unknown factor without the function code for testing.
This is the approach I ended up taking. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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