Countifs, but only last 5 occurrences

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
471
Office Version
  1. 365
Platform
  1. Windows
Hi could someone adjust this formula so it would count the last 5 occurrences ?
My data sheet has over 10,000 rows, have just shown small example

have attached photo for better understanding

Book1
CDEFGHIJ
2PETER3
35
4
5
6
7
8
9PETER12
10PETER1
11PETER3
12PETER214
13PETER215
14DAN8
15DAN2
16DAN1
17DAN4
18PAUL4
19PETER12
20PETER1
21PETER3
22PETER112
23PETER12
24PETER1
25PETER3
26PETER214
Sheet1
Cell Formulas
RangeFormula
J2J2=COUNTIFS($C$1:$C$9971,$F$2,$D$1:$D$9971,"",$E$1:$E$9971,">="&$F$3)
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I don't quite follow what is meant by count the last 5. This will count the number of rows that match your criteria, and if the value exceeds 5, only 5 will be reported back.
Excel Formula:
=MIN(5,SUMPRODUCT(($C$9:$C$9971=$F$2)*($D$9:$D$9971="")*($E$9:$E$9971>=$F$3)))
 
Upvote 0

Forum statistics

Threads
1,214,922
Messages
6,122,281
Members
449,075
Latest member
staticfluids

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