Formula to find, change and highlight Cell based on Specific criteria

westc4

Board Regular
Joined
Aug 1, 2012
Messages
89
Office Version
  1. 365
Platform
  1. Windows
I have three columns of data, Assignment, Category, and Amount. What I need is to find when the Category is equal to USOCOO, within each Assignment, then find the Category with the highest Amount, then change the "USOCOO" to the highest Category and change cell color to 0.799981688894314.

Here is a sample of data: (there are thousands of lines and Assignments). The Amount may or may not be sorted by largest to smallest.
Assignment
Category
Amount
NEW CATEGORY
2532315992USOSTM 13,060.00
unchanged
2532315992USOCOO 151.44
USOSTM
2532315992USOSTM 119.06unchanged
2532315992USOCOO 1.38USOSTM
2533369197USODIG 49,934.62unchanged
2533369197USOCOO 3,496.50USODIG
2533369197USOPHF 15.38unchanged
2534243856USOVAL 840.00unchanged
2534243856USOMIV 45.00unchanged
2534243856USOCOO 3.87USOVAL
2534259251USODIG 365.04unchanged
2534259251USOMBR 33.73unchanged
2534259251USOCOO 29.12USODIG
2534259251USOPHF 0.11unchanged
2534259360USOMBR 8,750.00unchanged
2534259360USOMBR 175.00unchanged
2534259360USOCOO 23.74USOMBR
2534259360USOCOO 0.47USOMBR
2534344017USOMIV 105.00unchanged
2534344017USOCOO 9.03MSOMIV
2534384470USOSUN 1,675.00unchanged
2534384470USOCOO 12.69USOCOO
2534402150
USOADV
2,093.84unchanged
2534402150USOCOO 166.98USOADV
2534482508USOADV
360.00
unchanged
2534482508USOMIV 105.00unchanged
2534482508USOCOO 19.65USOADV
2534571551USOCNV
21,889.00unchanged
2534571551USOCOO 234.18USOCNV
2534678375USOCNV
779.00unchanged
2534678375USOCOO
56.48USOCNV
2534848168USODIG
9,687.02unchanged
2534848168USOMIV 4,134.00unchanged
2534848168USOPST 3,430.00unchanged
2534848168USOCOO 793.83USODIG
2534848168USOPHF 2.98unchanged

<colgroup><col><col><col></colgroup><tbody>
</tbody>

Thank you for your help!!
 

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.
Hi westc4,

If you have Excel 2016, I would suggest using the MAXIFS formula in combination with some sort of lookup formula.

If you don't have Excel 2016 but an earlier version, you will have to use a combination of array formulas.

Assuming your data starts in cell A2, I would use the following formula, making sure to hit Ctrl+Shift+Enter when entering the formula to make it an array formula.

{=IF(B2="USOCOO",INDEX($B$2:$B$37,MATCH(MAX(IF($A$2:$A$37=A2,$C$2:$C$37))&A2,$C$2:$C$37&$A$2:$A$37,0)),"unchanged")}

Three primary parts to this formula:

  1. IF(B2="USOCOO", - checks for your category condition
  2. MAX(IF($A$2:$A$37=A2,$C$2:$C$37)) - finds the max amount based on the assignment
  3. INDEX($B$2:$B$37,MATCH(MAX(IF($A$2:$A$37=A2,$C$2:$C$37))&A2,$C$2:$C$37&$A$2:$A$37,0)) - combines this max with the assignment and does a lookup for the proper category

Add in the "unchanged" category for the false condition and you should be set.

Hope this helps! If you found it useful, please shoot me a like.

Cheers!

Tyler
 
Upvote 0
Solution
One additional note is that if you are going to have to use this formula a lot, I would suggest doing the calculation and then copying/pasting as values. Performance of the file can regress with thousands upon thousands of array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,427
Messages
6,124,831
Members
449,190
Latest member
rscraig11

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