OzGrid

Array Formulas - Excel Array Formulas

< Back to Search results

 Category: [Excel]  Demo Available 

 

Array Formulas - Excel Array Formulas

 

What are Array Formulas? 

Excel Array formulas are very powerful and useful formulas that allow more complex calculations than standard formulas. The "Help" in Excel defines them as below:

"An array formula can perform multiple calculations and then return either a single result or multiple results. Array formulas act on two or more sets of values known as array arguments."

IMPORTANT - Before we Start: Videos

When I first discovered array formulas may years ago, I thought I had found the answer to ALL my spreadsheet problems. I Started using them willy nilly and paid the price.

Perhaps the number one rule with arrays is, only use them when needed and know when to use them. I have seen many users using array formulas in instances when a standard Excel formula will do the job (eg; one of the database functions). Too many array formulas WILL slow down recalculation, saving, opening and closing.

I have even seen "so called" experienced users recommending them to other Excel users looking for help on a simple formula. This is usually due to inexperience and/or laziness. This is very irresponsible, as the person looking for help will also find themselves using them as their first port of call. So it is important to know when to use them and when not to. 

It is fair to say that even my examples below are really an incorrect use of array formulas, but in the interest of keeping things simple I have used them.

Array Formula Rules:

Before we show some examples of array formulas it is important to know 4 fundamental rules.

  • Each Argument Within An Array Must Have The Same Amount Of Rows And Columns.
  • You Must Enter An Array By Pushing Ctrl+Shift+Enter.
  • You Cannot Add The {} (Braces) That Surround An Array Yourself, Pushing Ctrl+Shift+Enter Will Do This For You.
  • You Cannot Use An Array Formula On An Entire Column.

Pet Shop Example:

Suppose you have 5 Columns of data each with 200 rows.
Column A is used to keep track of the sex of each dog sold i.e. Male or Female
Column B is used to keep track of the breed of the dogs sold.
Column C is used to keep track of the age of the dogs sold.
Column D is used to keep track whether the dog is sterilized or not i.e. Yes or No
Column E is used to keep track of the cost of the dog sold.

  • To Count The Number Of Male Poodles Sold: 
    =SUM(($A$2:$A$200="Male")*($B$2:$B$200="Poodle"))
  • To Count The Number Of Male Poodles Sold Over 3 Years Old:
    =SUM(($A$2:$A$200="Male")*($B$2:$B$200="Poodle")*($C$2:$C$200>2))
  • To Get The Total Cost Of Male Spaniels Sold:
    =SUM(IF($A$2:$A$200="Male",IF($B$2:$B$200="Spaniel",$E$2:$E$200,0),0))
  • To Find Out The Average Age Of Male Dogs Sold:
    =AVERAGE(IF($A$2:$A$200="Male",$C$2:$C$200))
  • To Find Out The Average Cost Of Male Dogs Sold Over 2 Years Old:
    =AVERAGE(IF($A$2:$A$200="Male",IF($C$2:$C$200>2,$E$2:$E$200)))
  • To Find Out The Minimum Age Of Dogs Sold That Are Sterilized:
    =MIN(IF($D$2:$D$200="Yes",$C$2:$C$200))

All the above formulas must be entered with Ctrl+Shift+Enter

TIP: If you are having problems writing an array formula to sum your totals then use the Conditional sum wizard, Tool>Wizard>Conditional sum. If you don't see it then you will need to add it via Tools>Add-ins>Conditional sum wizard.

While using array formulas can be very handy they have one draw back and that is, too many of them within your workbook WILL slow down Excels recalculations.

If you will need a lot of array formulas within the same workbook consider using, pivot tables the database functions instead. These are ideal for extracting information from tables and databases.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

Excel VBA Macro - Adding Values to an Excel ComboBox
Advanced Excel Dynamic Named Ranges
Excel Advanced Filter
Excel: Alternate Row Colors/Color Banding

 

Microsoft ® and Microsoft Excel ® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)