Function · Shape arrays
Excel CHOOSECOLS function
The Excel CHOOSECOLS function returns the columns you number. Columns 1 and 3 of city, state, and ZIP are the city and the ZIP, without the state.
Syntax =CHOOSECOLS(array, col_num1, [col_num2], ...)
=CHOOSECOLS(A1:C2,1,3)Arguments
| Name | Required | What to pass |
|---|---|---|
| array | Required | The source. Column 1 is the first column of this array. |
| col_num1 | Required | The first column to return. A negative number counts from the right. |
| col_num2 | Optional | More columns, in the order you want them spilled. |
Examples
City and ZIP, skipping the state
=CHOOSECOLS(A1:C2,1,3)Result Austin 78701 and Dallas 75201
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Austin | TX | 78701 | Austin | 78701 | |
| 2 | Dallas | TX | 75201 | Dallas | 75201 |
CHOOSECOLS keeps the columns you number and drops the rest. From city, state, and ZIP, columns 1 and 3 are Austin with 78701, and Dallas with 75201. The state column is column 2 and it is not in the spill. The result is still two rows because both source rows are kept.
Column 1 means the first column of the array, which is column A only when the array starts in column A. WRAPROWS of Austin, Dallas, Houston, San Antonio, Fort Worth, El Paso, Plano, and Arlington, three to a row, has Austin, San Antonio, and Plano in column 1. CHOOSECOLS of that spill, column 1, returns those three names. A negative index counts from the right, so -1 is the ZIP. INDEX can return one column in older Excel. CHOOSECOLS can return several, in any order. Excel 2021 does not have it.