Average n numbers after the first not equal to zero

omerfri

New Member
Joined
Apr 8, 2019
Messages
1
Hi,
I need to average the first n (let's say 3) numbers in a column, from the first one that is not equal to zero.
For example:
152
252
253
203
003

<tbody>
</tbody>

In the left column, checking from down up, first there is a zero, and the average of the following 3 numbers is 2, so the answer is 2.
In the center column there is a zero, and then another zero that the formula need to ignore. The average of the three following is 5, so that's the answer. The answer for the right column is 3.

Please anybody can help me with a formula?+

EDIT:
Just one thing - i didnt mention - the checking of a non zero number is from down to up (from the bottom of the list).
Thanks again.
 
Last edited by a moderator:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

say you data is located in range A2:C6

You could list the letters A B C in cells E1, F1, G1

Then in cell E2 you could test following formula :

Code:
=AVERAGE(INDIRECT(E1&IF(ISERROR(MATCH(0,A1:A6,0)-1),MATCH(1E+30,A:A),MATCH(0,A1:A6,0)-1)-2&":"&E1&IF(ISERROR(MATCH(0,A1:A6,0)-1),MATCH(1E+30,A:A),MATCH(0,A1:A6,0)-1)))

And copy it to both B2 and C2 ...

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,454
Members
449,083
Latest member
Ava19

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