How to make Excel 2010 auto-fill new row with formulas?
This is not a dream, and you're right: Excel's AI triggers these things, and not only for tables. Just a small example to demonstrate:
- Open a new workbook and fill in column
A
with increasing numbers, e.g.:
1 2 3 4 5
- Next, in column B add any simple formula, e.g.
=A1*10
and autofill down the list of numbers to get this:
1 10 2 20 3 30 4 40 5 50
- Now, to see how AI works, type
6
(or any number) in the next row under5
(this should beA6
in the context) and press either TAB OR ENTER - as you normally do. - Enjoy the magic! (:
This should not occur for formulas only - formatting may be autoapplied as well, e.g. when you add a new column right to the data set, and your "Header" (1st row) has special formatting (black fill / white text) and start typing values there - most likely it will be colored the same way.
I can't provide the full list of cases, but I think you got the clue!)
You can avoid the autofill feature completely with array formulas. Just enter the formula like normal but append :column
at the end of each cell reference and then press Ctrl+Shift+Enter. The formula will then be applied immediately to all cells in the column without dragging anything
Edit:
Newer Excel versions will automatically use array formulas to fill down when there's a new data row
Beginning with the September 2018 update for Office 365, any formula that can return multiple results will automatically spill them either down, or across into neighboring cells. This change in behavior is also accompanied by several new dynamic array functions. Dynamic array formulas, whether they’re using existing functions or the dynamic array functions, only need to be input into a single cell, then confirmed by pressing Enter. Earlier, legacy array formulas require first selecting the entire output range, then confirming the formula with Ctrl+Shift+Enter. They’re commonly referred to as CSE formulas.
Guidelines and examples of array formulas
If you're on an older version of Excel or want to know more about array formulas then continue reading
For example putting =B3:B + 2*C3:C
in D3 and Ctrl+Shift+Enter is equivalent to typing =B3 + 2*C3
and dragging all the way down in a table starting from row 3
That's fast to type, but has a disadvantage that unused cells at the end (outside the current table) are still calculated and show 0. There's an easy way to hide the 0s. However the even better way is to limit the calculation to the last column of the table. Knowing that in an array formula you can use X3:X101
to apply to only cells from X3 to X101 we can use INDIRECT
function to achieve the same effect
- Enter
=LOOKUP(2, 1/(A:A <> ""), A:A)
in some cell outside the table to find the last non-blank cell in the table and name itLastRow
. Alternatively use=COUNTA(A3:A) + 2
when the table's first row is 3 - Then instead of
B3:B
use=INDIRECT("B3:B" & LastRow)
For example if you want cells in column D to contain the products of cells in B and C, and column E contains sums of B and C, instead of using D3 = B3*C3
and E3 = B3 + C3
and drag down you just put the below formulas in D3 and E3 respectively and press Ctrl+Shift+Enter
=INDIRECT("B3:B" & LastRow) * INDIRECT("C3:C" & LastRow)
=INDIRECT("B3:B" & LastRow) + INDIRECT("C3:C" & LastRow)
From now on every time you add data to a new row, the table will be automatically updated
Array formula is very fast since the data access pattern is already known. Now instead of doing 100001 different calculations separately, they can be vectorized and done in parallel, utilizing multiple cores and SIMD unit in the CPU. It also has the below advantages:
- Consistency: If you click any of the cells from E2 downward, you see the same formula. That consistency can help ensure greater accuracy.
- Safety: You cannot overwrite a component of a multi-cell array formula. For example, click cell E3 and press Delete. You have to either select the entire range of cells (E2 through E11) and change the formula for the entire array, or leave the array as is. As an added safety measure, you have to press Ctrl+Shift+Enter to confirm the change to the formula.
- Smaller file sizes: You can often use a single array formula instead of several intermediate formulas. For example, the workbook uses one array formula to calculate the results in column E. If you had used standard formulas (such as
=C2*D2
,C3*D3
,C4*D4
…), you would have used 11 different formulas to calculate the same results.Guidelines and examples of array formulas
For more information read
- Create an array formula