Array Formulae: Minimise The Number of Array Operations
Array Formulae: Minimise The Number of Array Operations
Array formulae are one of Excel’s most powerful features, although not always the easiest to
use. Look at Bob Umlas's excellent paper at http://www.emailoffice.com/excel/arrays-
bobumlas.html for many examples of Array formulae, and also Chip Pearson's page at
http://www.cpearson.com/excel/array.htm .
Single-cell array formulae are evaluated multiple times, depending on the number of cells
referred to in the formula. This can take significant time, and may or may not be faster than the
alternatives.
A range array formula covering multiple cells may be faster to calculate than individual
formulae in each cell (although the speed advantage seems less in Excel97 and Excel2000).
Because array formulae and functions like SUM which reference ranges influence the sequence
in which Excel calculates, you should try and avoid mixing row and column references or
overlapping array references.
See SUMIF example for a worked example of this. The downloadable FastExcel Sample
Problem also has an example which shows the method and the considerable time saving which
is often achievable.
Array Formulae
Page 1 of 3
You can use SUMPRODUCT for multiple condition array formulae as follows:
SUMPRODUCT(--(Condition1),--(Condition2),RangetoSum)
Note that the size and shape of the ranges or arrays used in the conditional expressions and
range to sum must be the same, and cannot contain entire columns.
You can also directly multiply the terms inside SUMPRODUCT rather than separate them by
commas:
SUMPRODUCT((Condition1)*(Condition2)*RangetoSum)
But this is usually slightly slower than using the comma syntax, and gives an error if the range
to sum contains a text value.
However it is slightly more flexible in that the range to sum may have for instance multiple
columns when the conditions only have 1 column.
{=SUM($D$2:$D$10301*$E$2:$E$10301)}
=SUMPRODUCT($D$2:$D$10301*$E$2:$E$10301)
=SUMPRODUCT($D$2:$D$10301,$E$2:$E$10301)
These three formulae all produce the same result, but the third formula using the comma syntax
for SUMPRODUCT only takes about 77% of the time to calculate that the other two formulae
need.
Array Formulae
Page 2 of 3
Array and Function Calculation Bottlenecks
Excel’s calculation engine is optimised to exploit array formulae and functions that reference
ranges. However some unusual arrangements of these formulae and functions can sometimes,
but not always, cause significantly increased calculation time.
If you find a calculation bottleneck involving array-formulae and range functions look for:
• Array Formulae are concise: You can eliminate columns and rows by packing the
calculations into an array formula.
• Array Formulae are powerful: You can easily perform many complex calculations such
as multiple conditional sums and counts using array formulae.
• Array Formulae save disk space: Using array formulae covering a range of cells can
reduce workbook size compared to equivalent individual formulae. Memory used does
not usually seem to reduce significantly.
• Array Formulae offer increased protection: Excel will only allow you to alter a
complete array formula block so the user is prevented from accidentally changing a
single formula.
• The Black-Box effect: Array Formulae can be complex and hard to understand. Most
Excel users do not understand array formulae at all. This can reduce confidence and
usability of your spreadsheet.
• Calculation Overhead: Each time an array formula is calculated all of the virtual cells
needed by the array formula are calculated, regardless of whether this is required or not.
This may cause the array formula to be slower than a non-array equivalent set of
formulae.
• Requirement for all components of the array formulae to be the same size: This may
require the array formula to perform a large number of unnecessary calculations. This
problem frequently occurs in a SUM with multiple conditions problem. Sorting and
then calculating the subset range that needs to be summed may often make significant
calculation speed improvements. The SUMIF example shows how several hours of
Array Calculations can be reduced to under a second.
Array Formulae
Page 3 of 3