Counting occurences in last 150 rows of 1000

  • Thread starter Thread starter Legacy 178656
  • Start date Start date
L

Legacy 178656

Guest
Hi,
I have 4 columns with numbers in ranging from 1 to 99.
.. A B C D
1
2
...
1699


I add new entry every day.
( 1 entry = 4 new numbers in A to D)

What I'm trying to do on another sheet is to count the number of occurrences of each number (1 to 99) but only in the last (x) entries.

So if I'm on row 1700 I just want to count how many times each number occurs from row 1700-(x).

x will be the value placed in a cell which I can change eg 150.

I've been at this for hours and can't work it out. Any help would be appreciated before I go round the twist.

Thanks, Pete.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Oh, and the title is a bit misleading, it should be, "Counting occurences in last x rows of total rows" not 1000
 
Upvote 0
Sheet1, A:D, is supposed to house data.

Sheet2

E2 houses the parameter value like 150 to indicate "x last records".

=COUNTIF(OFFSET(INDEX(Sheet1!A:A,MATCH(9.99E+307,Sheet1!A:A)),0,0,-E2,4),7)

This counts the occurrences of the number 7.

Adjust to suit.
 
Upvote 0
OMG!

Genius, I salute you!
This works and so fast too.

I'll try and work out how this works.
Again thank you.

Pete
 
Upvote 0
OMG!

Genius, I salute you!
This works and so fast too.

I'll try and work out how this works.
Again thank you.

Pete

You are welcome. Thanks for providing feedback.

Although what follows is a bit terse, the OFFSET bit constructs using the calculated last cell in A a range of E2 rows high and 4 columns wide. This range is then fed to the outer COUNTIF as the reference to look at.
 
Upvote 0

Forum statistics

Threads
1,224,563
Messages
6,179,527
Members
452,923
Latest member
JackiG

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