Hi All,
I need a function (or VBA code) that will perform the following average:
1
2
5
0
1
0
0
I need to check if the last cell in the column is 0. If not, check the second to last cell. If that is not 0, check the next. If the next value is nonzero, take the average of all values including the nonzero value, and include 0 values that occur after that (all but the first value and the length of each column will be arbitrary).
For example, in the above example I would get (1+0+5+2)/4=8/4=2.
I imagine that one way of going about this would be reversing the order of the cells, and then taking average only after the first nonzero value. After the first nonzero value, however, 0s could be averaged. Maybe there is a more speed efficient way...
Any help would be much appreciated,
Thanks!
I need a function (or VBA code) that will perform the following average:
1
2
5
0
1
0
0
I need to check if the last cell in the column is 0. If not, check the second to last cell. If that is not 0, check the next. If the next value is nonzero, take the average of all values including the nonzero value, and include 0 values that occur after that (all but the first value and the length of each column will be arbitrary).
For example, in the above example I would get (1+0+5+2)/4=8/4=2.
I imagine that one way of going about this would be reversing the order of the cells, and then taking average only after the first nonzero value. After the first nonzero value, however, 0s could be averaged. Maybe there is a more speed efficient way...
Any help would be much appreciated,
Thanks!