Highlight duplicate rows if the summation of values of duplicate rows equals other column value

Prativa

New Member
Joined
Jul 11, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello Team,

I am having a scenario where I need to find duplicate rows based on three columns let's say in my case it would be Col A,Col B and SL QTY
Once I found duplicate rows my next action would be the sum of values of "QTY" column let's say in my case if it would C2+C3 since row 2 and row 3 are duplicates, next I have to compare the value of C2+C3 = E2.
If C2+C3 equals E2-->highlight the duplicate rows with green color
If C2+C3 > E2-->highlight the duplicate rows with yellow color
If C2+C3 <E2-->highlight the duplicate rows with orange color.

1657517991510.png


Kindly help me out on how to put this logic in conditional formatting dynamically since I will be having huge records in excel.

Thanks,
Prativa
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
setup 3 conditional format rules


green
=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2

yellow
=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)>$E2

orange
=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)<$E2

this assumes column E for every duplicate will be the same value

it will also highlight single rows

columns G,H,I are not needed but show the formula working for each condition

Book1
ABCDEFGHI
1ABQTYAMNTSLGreenYellowOrange
2100001ABCD-123-W500964.11000TRUEFALSEFALSE
3100001ABCD-123-W500964.11000TRUEFALSEFALSE
4100001ABCD-579-W4964.11FALSETRUEFALSE
5100001ABCD-579-W2964.11FALSETRUEFALSE
6100001ABCD-579-W1964.11FALSETRUEFALSE
7100001ABCD-123-A500964.11100FALSEFALSETRUE
8100001ABCD-123-A500964.11100FALSEFALSETRUE
9100001ABCD-123-B250964.1750TRUEFALSEFALSE
10100001ABCD-123-B250964.1750TRUEFALSEFALSE
11100001ABCD-123-B250964.1750TRUEFALSEFALSE
Sheet1
Cell Formulas
RangeFormula
G2:G11G2=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2
H2:H11H2=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)>$E2
I2:I11I2=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)<$E2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:E11Expression=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)<$E2textNO
A2:E11Expression=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)>$E2textNO
A2:E11Expression=SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2textNO
 
Upvote 0
if you do NOT want to highlight any single entries then use
these 3 rules instead

green
=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2)

yellow
=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)>$E2)

orange
=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)<$E2)

again columns G,H,I are to illustrate the formula

Book1
ABCDEFGHI
1ABQTYAMNTSLGreenYellowOrange
2100001ABCD-123-W500964.11000TRUEFALSEFALSE
3100001ABCD-123-W500964.11000TRUEFALSEFALSE
4100001ABCD-579-W4964.11FALSETRUEFALSE
5100001ABCD-579-W2964.11FALSETRUEFALSE
6100001ABCD-579-W1964.11FALSETRUEFALSE
7100001ABCD-123-A500964.11100FALSEFALSETRUE
8100001ABCD-123-A500964.11100FALSEFALSETRUE
9100001123565250964.1750FALSEFALSEFALSE
10100001ABCD-123-B250964.1750FALSEFALSETRUE
11100001ABCD-123-B250964.1750FALSEFALSETRUE
Sheet1
Cell Formulas
RangeFormula
G2:G11G2=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2)
H2:H11H2=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)>$E2)
I2:I11I2=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)<$E2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:E11Expression=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)<$E2)textNO
A2:E11Expression=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)>$E2)textNO
A2:E11Expression=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2)textNO



for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
A2:E100 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:
=AND(COUNTIFS($A$2:$A$11,$A2,$B$2:$B$11,$B2)>1,SUMIFS($C$2:$C$11,$A$2:$A$11,$A2,$B$2:$B$11,$B2)=$E2)
Note the range should be changed to match your data or exceed - my need an additional part of the AND() $A2<>""
Format [Number, Font, Border, Fill] format green
choose the format you would like to apply when the condition is true
OK >> OK

repeat for other colours
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,765
Members
449,049
Latest member
greyangel23

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