# Rolling average with blanks in raw data

#### akardar1

##### New Member
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

To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

#### footoo

##### Well-known Member
=COUNT(OFFSET(A1,COUNT(A:A),0,-30))

Note : you can't put in A1

Last edited:

#### footoo

##### Well-known Member
To put in A1, something like :
=COUNT(OFFSET(A1,COUNT(A2:A10000),0,-30))

Thank you !!

#### footoo

##### Well-known Member

Thank you !!
I don't think it does what you want.
Will look at again tomorrow.

#### footoo

##### Well-known Member
Try this :

=COUNT(OFFSET(A1,LOOKUP(2,1/(A2:A10000<>""),ROW(A2:A10000))-1,0,-30))

#### Osvaldo Palmeiro

##### Well-known Member

... i would like A1 to count A6:A36..always counting back 30..

So, you want to count 31 cells, is it" ?

VBA Code:
``=COUNT(OFFSET(INDIRECT("A"&MATCH(9.99E+307,A:A)),,,-31))``

#### footoo

##### Well-known Member
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:

#### Osvaldo Palmeiro

##### Well-known Member
... but the OP wants it in A1.
Yes, you can place it in any cell out of counting range, including A1.

#### footoo

##### Well-known Member
Correction :
=COUNT(OFFSET(INDIRECT("A"&MATCH(9.99E+307,A2:A10000)-1),,,-31))

Replies
5
Views
246
Replies
3
Views
76
Replies
4
Views
204
Replies
3
Views
61
Replies
3
Views
75

1,127,529
Messages
5,625,351
Members
416,096
Latest member
forevans

### 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.

### Which adblocker are you using?

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

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