search
HomeTopicsexcelExcel EXPAND function to extend array to specified dimensions

The tutorial introduces a new Excel 365 dynamic array function that can expand an array to the desired dimensions with a value of your choosing.

Want to increase an array to a specified number of rows or columns so that all similar arrays in your worksheet have the same size? In Excel 365, that can be done with one simple formula. Meet the brand-new EXPAND function that can grow an array to any dimensions you set.

Excel EXPAND function

The EXPAND function in Excel is designed to pad an array with a value of your choice to the specified row and column dimensions.

The syntax includes the following arguments:

EXPAND(array, rows, [columns], [pad_with])

Where:

Array (required) - the original array.

Rows (optional) - the number of rows in the returned array. If omitted, new rows are not added, and the columns argument must be set.

Columns (optional) - the number of columns in the returned array. If omitted, new columns are not added, and the rows argument must be set.

Pad_with - the value to fill new cells with. If omitted, defaults to #N/A.

Excel EXPAND function to extend array to specified dimensions

Tip. To remove unwanted rows or columns from an array, use the DROP function.

EXPAND function availability

Currently, the EXPAND function is available in Excel for Microsoft 365 (Windows and Mac) and Excel for the web.

How to use the EXPAND function in Excel

To increase an array to the desired size, construct an EXPAND formula in this way:

  1. For array, supply a range of cells or an array of values returned by another formula.
  2. For rows and columns, provide positive numbers that are greater than the number of rows and columns in the original array. Note that these arguments define the dimensions of the resulting array, not the number of rows or columns to add. In each particular formula, either rows or columns must be set. The omitted argument defaults to the corresponding dimension (rows or columns) of the source array.
  3. For pad_with, specify the value to populate the new cells added to the array. If it's a text value, enclose it in double quotes. If it's a numeric value, use it without quotation marks. If not provided, the new cells will be padded with the #N/A error.

Being a dynamic array function, EXPAND needs to be entered only in one cell, and it automatically spills the results into as many cells as specified in the rows and columns arguments.

For example, to expand the array C6:D13 to 12 rows and 3 columns, the formula is:

=EXPAND(C6:D13, 12, 3)

As the pad_with argument is not set, the above formula will pad the newly added cells with the #N/A error. To change the default behavior, supply any value you want for the pad_with argument. For example, you can pad the new array values with a hyphen:

=EXPAND(C6:D13, 12, 3, "-")

Excel EXPAND function to extend array to specified dimensions

Below you will find a few more examples of using the EXPAND function in Excel to grow an array in a specific direction.

Expand array to a certain number of rows

To extend an array down to the desired number of rows, define the rows argument and omit columns.

For instance, to increase the initial array to a total of 12 rows, use this formula:

=EXPAND(C6:D13, 12, , "-")

Because columns should not be extended, we type a comma after rows, and after the comma enter the padding value.

Excel EXPAND function to extend array to specified dimensions

Expand array to a certain number of columns

To add more columns to an array, define the columns argument and omit rows.

For example, here's how you can extend the source array to the right, so it has a total of 4 columns:

=EXPAND(A4:C15, , 4, "-")

Excel EXPAND function to extend array to specified dimensions

How to expand an array left and up

The EXPAND function is designed to extend an array right and down. To add cells to the left and above of the source array, you will have to work out your own solution.

Suppose you have an array of values in B4:C12. You aim to add 3 rows above and 1 column to the left of the original array. To better understand the mechanics, we'll first perform each task individually, and then put all the pieces together.

Add columns to left

To extend the array horizontally, you can use the HSTACK function to append a given number of empty columns to the left of your array. In this example, we add 1 blank column using this formula:

=HSTACK(D4:D12, B4:C12)

Notice that an empty array that you stack (D4:D12) should have the same number of rows as the source array and should be supplied first in the formula. As a result, a column of zero values is added to the left of the original array.

Excel EXPAND function to extend array to specified dimensions

Add rows above

To expand the array vertically, leverage the VSTACK function to place a certain number of empty rows above the first row of your original array.

In our case, the following two ranges with the same number of columns are stacked, an empty array coming first:

=VSTACK(B14:C16, B4:C12)

In the result, 3 rows with zero values are added to the top of the initial array.

Excel EXPAND function to extend array to specified dimensions

Add rows above and columns to left

To expand an array vertically and horizontally, nest the VSTACK and HSTACK function one into the other. In our case, the formula takes this form:

=VSTACK(B14:D16, HSTACK(D4:D12, B4:C12))

And produces this result:

Excel EXPAND function to extend array to specified dimensions

Pad an array up and left with custom value

By default, the VSTACK and HSTACK functions return zeros instead of blank cells. To pad the new cells with a custom value, nest a combination of IF and ISBLANK within each stack function, which will replace blanks with the value you specify.

For example, to get the new cells padded with a hyphen, the formula is:

=VSTACK(IF(ISBLANK(B14:D16),"-", B14:D16), HSTACK(IF(ISBLANK(D4:D12),"-", D4:D12), B4:C12))

Excel EXPAND function to extend array to specified dimensions

To extend an array with blank cells, use this formula:

=VSTACK(IF(ISBLANK(B14:D16),"", B14:D16), HSTACK(IF(ISBLANK(D4:D12),"", D4:D12), B4:C12))

Excel EXPAND function to extend array to specified dimensions

Split strings and expand arrays

This example shows how to use the EXPAND and TEXTSPLIT functions together to split a text string by a specific delimiter in individual columns, and then grow the final array to the desired size.

Let's say you have a column of strings like column B in the image below. Each string has several values separated with a particular delimiter (a comma and a space in our case). Your goal is to split each string into separate cells, so that all the resulting arrays have the same number of columns.

To accomplish the task, enter this formula in E4:

=EXPAND(TEXTSPLIT(B4, ", "), , COLUMNS(E3:H3), "-")

In this formula:

  • TEXTSPLIT separates the values in B4 using a comma and a space (", ") as the delimiter.
  • COLUMNS computes the number of columns in the output array.
  • EXPAND extends the returned array to the right padding missing values with hyphens ("-").

Drag the formula down through E15 and you'll get this result:

Excel EXPAND function to extend array to specified dimensions

EXPAND function not working

If the EXPAND function works incorrectly in your Excel or throws an error, the following tips will help you pin down the cause and fix it.

#VALUE! error

Occurs if the value used for the rows or columns argument is less than the total number of rows or columns of the source array.

#N/A error

Appears in padded cells if the pad_with argument is not set.

#NAME? error

Occurs if either the function's name is misspelled or EXPAND is not available in your Excel version. Currently, it's only supported in Excel 365 and Excel for the web. More details can be found in Fixing the #NAME error in Excel.

#SPILL! error

Occurs when there are not enough empty cells to output the expanded array. In most situations, clearing the obstructing cells fixes the error at once. For more information, please see How to fix #SPILL! error in Excel.

That's how to use the EXPAND function in Excel to extend an array to as many rows and columns as your business logic requires. I thank you for reading and hope to see you on our blog next week!

Practice workbook for download

Excel EXPAND formula - examples (.xlsx file)

The above is the detailed content of Excel EXPAND function to extend array to specified dimensions. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MEDIAN formula in Excel - practical examplesMEDIAN formula in Excel - practical examplesApr 11, 2025 pm 12:08 PM

This tutorial explains how to calculate the median of numerical data in Excel using the MEDIAN function. The median, a key measure of central tendency, identifies the middle value in a dataset, offering a more robust representation of central tenden

Google Spreadsheet COUNTIF function with formula examplesGoogle Spreadsheet COUNTIF function with formula examplesApr 11, 2025 pm 12:03 PM

Master Google Sheets COUNTIF: A Comprehensive Guide This guide explores the versatile COUNTIF function in Google Sheets, demonstrating its applications beyond simple cell counting. We'll cover various scenarios, from exact and partial matches to han

Excel shared workbook: How to share Excel file for multiple usersExcel shared workbook: How to share Excel file for multiple usersApr 11, 2025 am 11:58 AM

This tutorial provides a comprehensive guide to sharing Excel workbooks, covering various methods, access control, and conflict resolution. Modern Excel versions (2010, 2013, 2016, and later) simplify collaborative editing, eliminating the need to m

How to convert Excel to JPG - save .xls or .xlsx as image fileHow to convert Excel to JPG - save .xls or .xlsx as image fileApr 11, 2025 am 11:31 AM

This tutorial explores various methods for converting .xls files to .jpg images, encompassing both built-in Windows tools and free online converters. Need to create a presentation, share spreadsheet data securely, or design a document? Converting yo

Excel names and named ranges: how to define and use in formulasExcel names and named ranges: how to define and use in formulasApr 11, 2025 am 11:13 AM

This tutorial clarifies the function of Excel names and demonstrates how to define names for cells, ranges, constants, or formulas. It also covers editing, filtering, and deleting defined names. Excel names, while incredibly useful, are often overlo

Standard deviation Excel: functions and formula examplesStandard deviation Excel: functions and formula examplesApr 11, 2025 am 11:01 AM

This tutorial clarifies the distinction between standard deviation and standard error of the mean, guiding you on the optimal Excel functions for standard deviation calculations. In descriptive statistics, the mean and standard deviation are intrinsi

Square root in Excel: SQRT function and other waysSquare root in Excel: SQRT function and other waysApr 11, 2025 am 10:34 AM

This Excel tutorial demonstrates how to calculate square roots and nth roots. Finding the square root is a common mathematical operation, and Excel offers several methods. Methods for Calculating Square Roots in Excel: Using the SQRT Function: The

Google Sheets basics: Learn how to work with Google SpreadsheetsGoogle Sheets basics: Learn how to work with Google SpreadsheetsApr 11, 2025 am 10:23 AM

Unlock the Power of Google Sheets: A Beginner's Guide This tutorial introduces the fundamentals of Google Sheets, a powerful and versatile alternative to MS Excel. Learn how to effortlessly manage spreadsheets, leverage key features, and collaborate

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version