Dynamic Arrays 1

During the years we have been using Excel, we have come to understand that a formula calculates a value. Meaning, a single value. Right? Like … we write a formula, hit Enter, and the result is displayed in the cell.

Easy … that is how we have been using Excel for decades.

Multiple Values

But … formulas can return multiple values (an array of values).

Historically, these types of array formulas were somewhat complicated to create and required pressing special keys to enter. As a result, many Excel users did not take advantage of them.

However … times have changed!

In the most recent versions of Excel, writing and managing such formulas is greatly simplified and no special keys are required. This makes it much easier to take advantage of these types of formulas.

Spill Range

But … hang on Jeff!

If I write a formula that returns multiple results, what happens? Does just the first result appear in the cell? Or what? Here’s how that works.

When you write a formula that returns multiple values (an array), the results spill out of the formula cell into the adjacent cells (called the spill range). Wait … what? Crazy … I know! And super cool. And, it gets even better.

If the number of results returned by the formula changes over time, the number of cells used to display the results changes accordingly. That is, it is dynamic. Thus the term Dynamic Array.

Dynamic Array Series

This is the first post in the Dynamic Arrays series where we’ll explore this concept. Hang on tight, it’s gonna be a wild ride 😉

Note: this capability is available at the time of this writing in Excel 365 subscription versions, and isn’t available in perpetual license versions of Excel such as Excel 2019, 2016, 2013, and so on.

Video

Functions that return multiple values

I know what you may be thinking right about now. What type of formula returns multiple results? I mean the functions I use all the time like SUM, AVERAGE, MIN, MAX, COUNT and so on compute a single value. It is hard to image a function that returns multiple values.

Well, there are several functions that are designed specifically to return multiple values … the first of which we’ll discuss is UNIQUE.

UNIQUE

The UNIQUE function is designed to return a list of the unique values found in a range. And there it is. It returns a list … that is … multiple values.

For example, let’s say we have a table named Table1 that looks like this:

A screenshot of an Excel table, with 3 columns: TransID, Account, and Amount

And, let’s say we wanted to create a list of the accounts without any duplicate accounts. That is, we wanted to create a list like this:

A screenshot a list of the unique accounts from Table 1.

To do this, we use the UNIQUE function. The argument is the Account column in our table:

=UNIQUE(Table1[Account])

When we type this formula, and press Enter … wow! That single formula actually creates the entire list:

A screenshot of a list of unique accounts from table 1

We write one formula into a single cell. That formula returns multiple results. The first result is displayed in the formula cell and the remaining results spill out into the adjacent cells (the spill range).

This spill range is dynamic … meaning if we add a row to Table1 that includes a new account, the new account will automatically appear in our account list that was created with the UNIQUE function. For example, if Table1 gets a new row for Internet, the formula dynamically updates the spill range accordingly, like this:

Excel formula now returns Internet

You’ll notice that the list of accounts is displayed in the order in which they appear in the data source. Travel is first, Meals second, and so on. What if we wanted to display our list in alphabetical order? Well, that leads us to our next dynamic array function, SORT.

SORT

The SORT function is designed to sort the range. The default sort order is ascending, but we have a few options and arguments if we want to get fancy. In our case, a simple ascending sort is what we are after, so we simply wrap the SORT function around our UNIQUE function, like this:

=SORT(UNIQUE(Table1[Account]))

When we press Enter … bam:

A screenshot of a sorted list of accounts from table 1

Again, this list is dynamic. So, when new accounts are added to the data table, our list of accounts is updated accordingly. Excellent!

Cool?

What do you think about this capability? Let me know by posting a comment below, thanks!

Sample file

Posted in , ,

Jeff Lenning

I love sharing the things I've learned about Excel, and I built Excel University to help me do that. My motto is: Learn Excel. Work Faster.

Stay Connected

If you'd like to be notified when I write a new Excel article, enter your name and email and click SUBSCRIBE. You can unsubscribe anytime, and I will never sell your email address.

Want to learn Excel?

Our Campus Pass includes access to our entire Undergrad and Masters catalog. Gamification ensures it is the most fun you can have learning Excel :)

Leave a Comment





For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.