ICAEW.com works better with JavaScript enabled.
Exclusive

New Dynamic Array functions – be careful what you wish for

Author: Simon Hurst

Published: 08 Apr 2022

Exclusive content
Access to our exclusive resources is for specific groups of students, users, subscribers and members.
First of all, we'll cover the usual warning about Excel updates that are still in preview. They will initially only be available to those who have opted in to the more reckless update channels such as the Beta Channel and, as we saw recently with the XLOOKUP() function, they might change between the preview stage and eventual release.

The most recent Excel release to the Beta Channel includes 14 new functions: 3 for manipulating text and 11 for working with Dynamic Arrays. The Excel Community will be covering all of them in some detail in future posts but there is one particular function that is worth taking an early look at: VSTACK().

Just over one year ago I posted an article considering a range of recent Excel updates and bemoaning the fact that several of the updates seemed to fall a little way short of what they could have achieved. When looking at Dynamic Arrays, the article considered the inability of a Dynamic Array to be included as an Excel Table and also suggested that one very important function was missing from the first set of Dynamic Array functions: some sort of append function to allow multiple ranges of data to be consolidated into a single Dynamic Array:

"Like the new chart types, the issues with Dynamic Arrays, probably fall into the categories of both deficiencies and missed opportunities. The inability of a Dynamic Array to be part of an Excel Table would appear to be a deficiency. One of the great advantages of Dynamic Arrays is the ability to automate processes that would previously have needed manual intervention. However, the inability to 'spill within a Table' makes it much more difficult to create a chart or a PivotTable that dynamically adjusts to take account of a change in the number of cells into which a dynamic array formula spills:

For the missed opportunity, an APPEND() function is noticeable by its absence from the initial batch of specific dynamic array functions. This would allow the dynamic creation of a single table from multiple tables, something that is currently only easily possible using Power Query with its need to refresh."

The new VSTACK() function does just this, combining the rows from multiple ranges of Excel cells by position into a single Dynamic Array. There is also a horizontal equivalent called, appropriately enough, HSTACK() which combines columns. In the following screen shot we can see both functions used to combine the three Excel Tables. The available arguments for VSTACK() and HSTACK() are simply up to 254 individual ranges:

Excel screenshot

As you can see, the stacking operations can lead to blank cells in the resulting array when there are varying numbers of columns (for VSTACK()) or rows (for HSTACK()) in the source arrays. These are indicated with #N/A errors. Several of the other new Dynamic Array functions introduced at the same time as VSTACK() and HSTACK() include arguments to allow you to replace the empty cells resulting from changing the size and shape of arrays with specified 'padding' characters. Perhaps strangely, VSTACK() and HSTACK() don't include equivalent arguments, so instead you will need to use one of the error checking functions, such as IFNA(), to replace #N/A errors in your output array. Here, we have just used "" as the second argument of IFNA() to replace #N/A with an empty text string:

=IFNA(VSTACK(Table8[#All],Table9,Table10),"")

Excel screenshot

While these new functions are a really useful addition to the capabilities of Dynamic Arrays, the introduction of VSTACK() has completely ruined my standard introductory demonstration of the importance of Power Query. I used to triumphantly show how Power Query was the only reasonably straightforward way to easily consolidate ranges in Excel dynamically. Not any more it isn't.

Archive and Knowledge Base

This archive of Excel Community content from the ION platform will allow you to read the content of the articles but the functionality on the pages is limited. The ION search box, tags and navigation buttons on the archived pages will not work. Pages will load more slowly than a live website. You may be able to follow links to other articles but if this does not work, please return to the archive search. You can also search our Knowledge Base for access to all articles, new and archived, organised by topic.

Open AddCPD icon

Add Verified CPD Activity

Introducing AddCPD, a new way to record your CPD activities!

Log in to start using the AddCPD tool. Available only to ICAEW members.

Add this page to your CPD activity

Step 1 of 3
Download recorded
Download not recorded

Please download the related document if you wish to add this activity to your record

What time are you claiming for this activity?
Mandatory fields

Add this page to your CPD activity

Step 2 of 3
Mandatory field

Add activity to my record

Step 3 of 3
Mandatory field

Activity added

An error has occurred
Please try again

If the problem persists please contact our helpline on +44 (0)1908 248 250