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 ?
 

Some videos you may like

Excel Facts

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

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,206
Office Version
  1. 2016
Platform
  1. Windows
=COUNT(OFFSET(A1,COUNT(A:A),0,-30))

Note : you can't put in A1
 
Last edited:

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,206
Office Version
  1. 2016
Platform
  1. Windows
To put in A1, something like :
=COUNT(OFFSET(A1,COUNT(A2:A10000),0,-30))
 

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,206
Office Version
  1. 2016
Platform
  1. Windows
Try this :

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

Osvaldo Palmeiro

Well-known Member
Joined
Feb 24, 2009
Messages
627
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

... 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
Joined
Sep 21, 2016
Messages
3,206
Office Version
  1. 2016
Platform
  1. Windows
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:

footoo

Well-known Member
Joined
Sep 21, 2016
Messages
3,206
Office Version
  1. 2016
Platform
  1. Windows
Correction :
=COUNT(OFFSET(INDIRECT("A"&MATCH(9.99E+307,A2:A10000)-1),,,-31))
 

Watch MrExcel Video

Forum statistics

Threads
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.
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
Top