Need help with range value calculation

R

rda

I am looking for a formula that would allow me to calculate a maximum of the
last 4 numeric values in a row divided by their count. For example:

A B C D E F G H I J
1 34 43 30 36 42 44 32
2 82 22 14
3 22 32 44 44 32 12 44 18 22

With the values in the cells displayed I would need a formula to get the
results in the following cells:

4 34 38 35 35 35 35 37 37 38 38
5 82 52 39 39 39 39
6 22 27 32 35 38 33 33 26 24

The results will be used in another worksheet for additional calculations as
needed.

The formula I came up with are as follows:
A4: =A1
B4: =IF(COUNT($A$1:B1)>0,INT(SUM($A$1:B1)/COUNT($A$1:B1)),"")
C4: =IF(COUNT($A$1:C1)>0,INT(SUM($A$1:C1)/COUNT($A$1:C1)),"")
D4: =IF(COUNT($A$1:D1)>0,INT(SUM($A$1:D1)/COUNT($A$1:D1)),"")

This is where I'm stuck. If a value existed in D1 and a value in E1 then
the calculation should not include A1. In this instance there is no value in
either and E4 will have the same result as D4. Once we get to G1 then A1
must be dropped but the remaining need to be summed and divided by 4 with the
results in G4.

I hope I've explained my problem well and someone can come up with a simple
solution.

Thanks,
RDA
 
C

Castell

Remove the dollar signs from the formula in cell D4 and copy this formula
across to all cells to the right of D4.
 
R

rda

That was the simple solution and it would work if all cells had a value. But
in this case what I need to do is determine the last 4 cells that have a
value and divide it by 4. For example: Cells A1:C1 have values, cells D1:E1
do not, cells F1:G1 have values. The results calculation for B4 would be
A1(34)+B1(43)/2, C4 would be A1(34)+B1(43)+C1(30)/3, D4 and E4 would both be
the same as C4 since no value existed in D1 or E1, F4 would be
A1(34)+B1(43)+C1(30)+F1(36)/4, G4 would be B1(43)+C1(30)+F1(36)+G1(42)/4,
...., and J4 would be F1(36)+G1(42)+I1(44)+J1(32).

Any ideas how to accomplish this with a formula calculation?

Thanks in advance,
rda
 
D

Domenic

Try...

B4, confirmed with CONTROL+SHIFT+ENTER, and copied across:

=AVERAGE(INDEX($A1:B1,LARGE(IF($A1:B1<>"",COLUMN($A1:B1)-COLUMN($A1)+1),M
IN(4,COUNT($A1:B1)))):B1)

Hope this helps!
 
R

rda

Thank you Domenic... it works perfectly.

Domenic said:
Try...

B4, confirmed with CONTROL+SHIFT+ENTER, and copied across:

=AVERAGE(INDEX($A1:B1,LARGE(IF($A1:B1<>"",COLUMN($A1:B1)-COLUMN($A1)+1),M
IN(4,COUNT($A1:B1)))):B1)

Hope this helps!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top