Question

I have old Excel table that I need to manually fill and I made new Excel table where I used CTRL+T to fill in data automatically when typing formula in first row under the header/title cell.

My data is vertical in old:

Numbers     Average (for last 10 Numbers from Left Row)
5,780.00    
5,730.00    
6,600.00    
7,300.00    
6,120.00    
5,250.00    
5,210.00    
5,100.00    
5,770.00    
6,370.00    5923.00
6,000.00    5945.00
5,480.00    5920.00
5,120.00    5772.00
4,990.00    5541.00

This is how it should look, this is how I made it manually. Formula is:

=IF(L11<>"",AVERAGE(L2:L11),"")

Where forumula is in M row (Average) and checking and calculating for L row (Numbers). But for Table to auto-fill till last row, formula has to be made in first row, then Excel auto-fills.

Average:
5923.00 

is from this numbers:

    Numbers
    5,780.00    
    5,730.00    
    6,600.00    
    7,300.00    
    6,120.00    
    5,250.00    
    5,210.00    
    5,100.00    
    5,770.00    
    6,370.00

How can Average formula for 10 vertical numbers from L row be inserted into any cell above 5923.00 in Average - M Row.

I do know how to fill row, I could copy formula, press CTRL + SHIFT + DOWN to find end of my table and paste formula, but when new data comes (imported CSV that updates), new data would not be filled, I need Excel to auto-fill it.

Was it helpful?

Solution 2

You could add a test for which row the formula is in and only return a result if it's 11 or higher. Then you could enter it in the entire column table and it would fill automatically:

=IF(AND(ROW()>=11,L11<>""),AVERAGE(L2:L11),"")

ROW() returns the number of the row the fomula is in.

EDIT: Ok, here's a better one. Put this in M2 and copy down:

=IF(AND(ROW()>=11,L2<>""),AVERAGE(OFFSET($L$1,ROW()-10,0):OFFSET($L$1,ROW()-1,0)),"")

OTHER TIPS

Here is answer for all if needed, if you have by dates, old data up and new down, then average of first 10 items, can't be calculated in first 10 rows without issues where you have Average. Here is solution for one way direction:

=IF(AND((ROW())>=11,L2<>""),AVERAGE(OFFSET(M2,-9,-1,10)),"")

What Offset does, is goes up +9 places from current cell M2, then it goes 1 cell left, and from there takes 10 down to mark the range.

IF if statement is wrong it doesn't go left and up, thus no error, after and including ROW 10 it's true statement.

And this is more complicated to use with Table in Excel, when you have sorting by date, when newest date is on top, bottom is data that you can use for average:

=IF($A$2>$A$3,AVERAGE(OFFSET(M2,0,-1,10)),IF(AND((ROW())>=11,L2<>""),AVERAGE(OFFSET(M2,-9,-1,10)),""))

I have first IF (A2>A3) that checks how is table sorted: - if sorted newest - oldest (1st case) then it takes average from first row on the left, and down 10 places - if sorted opposite, it goes as said: left one place, and up 9, then takes 10 range.

Works like a charm, bit long, but it works!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top