Count only last duplicate or same values.

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Using Excel 2010
Hello,

I need a formula which can Count only last duplicate or same values. Data are in cells C6:P13 and result of counts in range C2:P3

Count Last Duplicates.xlsm
ABCDEFGHIJKLMNOPQ
1
2Count Last-->124216113
3Count Last-->0342146
4
5n1n2n3n4n5n6n7n8n9n10n11n12n13n14
601101010110100
711011010011101
811111010111100
910110011101110
1011001110110000
1100010101110010
1201001110100010
1301000111110110
14
15
Count Last Duplicates


Regards,
Moti
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Until a more elegant solution comes along...

Book1
ABCDEFGHIJKLMNOP
1
2Count Last-->1 2   42161 13 
3Count Last-->03 421     4  6
4
5n1n2n3n4n5n6n7n8n9n10n11n12n13n14
601101010110100
711011010011101
811111010111100
910110011101110
1011001110110000
1100010101110010
1201001110100010
1301000111110110
14
Sheet1
Cell Formulas
RangeFormula
C2:P2C2=IF(C$13=0,"",8-(AGGREGATE(14, 6, ROW($6:$13)/(C$6:C$13=0), 1)-5))
C3:P3C3=IF(C$13=1,"",8-(AGGREGATE(14, 6, ROW($6:$13)/(C$6:C$13=1), 1)-5))
 
Upvote 1
@kevin9999, as far as answer is correct solution is beautiful. It work perfect with sample data. But of course in the original data rows will be extending when new data added. After I change the range I am getting following result please can you take a look?

I do appreciate your help. Good Luck!

Count Last Duplicates.xlsm
ABCDEFGHIJKLMNOPQ
1
2Count Last-->1              
3Count Last-->0-2-2-1-2-20-2-1-1-2-2-2-1-2
4
5n1n2n3n4n5n6n7n8n9n10n11n12n13n14
601101010110100
711011010011101
811111010111100
910110011101110
1011001110110000
1100010101110010
1201001110100010
1301000111110110
1410110011101110
1511011010011101
16
17
Count Last Duplicates
Cell Formulas
RangeFormula
C2:P2C2=IF(C$1013=0,"",8-(AGGREGATE(14, 6, ROW($6:$1013)/(C$6:C$1013=0), 1)-5))
C3:P3C3=IF(C$1013=1,"",8-(AGGREGATE(14, 6, ROW($6:$1013)/(C$6:C$1013=1), 1)-5))

Kind Regards,
Moti
 
Upvote 0
Bit difficult without the full data you're using, but try changing the 8-( part of the formulas to 1008-( and see if that does what you want.
 
Upvote 0
@kevin9999, changing as per your instruction I am getting following results not sure may be VBA require for this problem.

Count Last Duplicates.xlsm
ABCDEFGHIJKLMNOPQR
1
2Count Last-->1              
3Count Last-->09989989999989981000998999999998998998999998
4
5n1n2n3n4n5n6n7n8n9n10n11n12n13n14
601101010110100
711011010011101
811111010111100
910110011101110
1011001110110000
1100010101110010
1201001110100010
1301000111110110
1410110011101110
1511011010011101
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Count Last Duplicates
Cell Formulas
RangeFormula
C2:P2C2=IF(C$1013=0,"",1008-(AGGREGATE(14, 6, ROW($6:$1013)/(C$6:C$1013=0), 1)-5))
C3:P3C3=IF(C$1013=1,"",1008-(AGGREGATE(14, 6, ROW($6:$1013)/(C$6:C$1013=1), 1)-5))


Kind Regards,
Moti
 
Upvote 0
Please check the link above query is solved by JohnTopley. thank you everyone who has looked this request.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,430
Members
449,158
Latest member
burk0007

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