Rolling average with blanks in raw data

akardar1

New Member
Joined
Dec 22, 2010
Messages
23
Hi Excel Team,

In Column A I have values like this from row 5 to 35 for instance:

5
6
blank
7
8
blank
blank
2

I would like to count the number of non-blank value and return that in A1... so I use =COUNT(A5:A35)
but the next day, i have a new value in cell A36, so now i would like A1 to count A6:A36..always counting back 30.. from the last value in column A
How do i amend my excel A1 formula ?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
=COUNT(OFFSET(A1,COUNT(A:A),0,-30))

Note : you can't put in A1
 
Last edited:
Upvote 0
To put in A1, something like :
=COUNT(OFFSET(A1,COUNT(A2:A10000),0,-30))
 
Upvote 0
Try this :

=COUNT(OFFSET(A1,LOOKUP(2,1/(A2:A10000<>""),ROW(A2:A10000))-1,0,-30))
 
Upvote 0
So, you want to count 31 cells, is it" ?

VBA Code:
=COUNT(OFFSET(INDIRECT("A"&MATCH(9.99E+307,A:A)),,,-31))
That's a much neater formula, but the OP wants it in A1.
So :
=COUNT(OFFSET(INDIRECT("A"&MATCH(9.99E+307,A2:A10000))-1,,,-31))
 
Last edited:
Upvote 0
Correction :
=COUNT(OFFSET(INDIRECT("A"&MATCH(9.99E+307,A2:A10000)-1),,,-31))
 
Upvote 0

Forum statistics

Threads
1,214,630
Messages
6,120,634
Members
448,973
Latest member
ChristineC

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