COLUMNS function
Counts the number of columns in a range or array.
Available in All versions of Excel, including Microsoft 365, Excel for the web and Excel for Mac
In every Excel versionWorks in Google Sheets
Syntax
COLUMNS(array)| Argument | What it means | |
|---|---|---|
array | Required | A range, array constant or formula that returns an array. |
Returns: A whole number: how many columns wide array is.
How COLUMNS works
COLUMNS measures width. =COLUMNS(B1:E4) returns 4 because the range spans B, C, D and E, regardless of what the cells contain - empty cells are counted too. It is the horizontal partner of ROWS.
It is most useful inside other formulas: to count how many periods a report covers, to work out the last column of a table for INDEX, or to check the size of a dynamic array produced by FILTER, UNIQUE or HSTACK. Because it only looks at the shape of the reference, it never returns an error for blank or text cells.
Examples
1How many quarters are in the report?
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Region | Q1 | Q2 | Q3 | Q4 |
| 2 | North | 12500 | 14200 | 13900 | 16100 |
| 3 | South | 9800 | 10400 | 11250 | 12030 |
| 4 | East | 7600 | 8150 | 8900 | 9420 |
| 5 | |||||
| 6 | 4 |
Result: 4
B to E is four columns.
2Number of data cells in a block
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Region | Q1 | Q2 | Q3 | Q4 |
| 2 | North | 12500 | 14200 | 13900 | 16100 |
| 3 | South | 9800 | 10400 | 11250 | 12030 |
| 4 | East | 7600 | 8150 | 8900 | 9420 |
| 5 | |||||
| 6 | 12 |
Result: 12
3 regions times 4 quarters gives 12 figures. Unlike COUNT, this counts blank cells too.
3Width of an array constant
| A | |
|---|---|
| 1 | 3 |
Result: 3
Commas separate columns and semicolons separate rows, so this array is 3 columns wide.
Tips
=INDEX(B2:E4, 1, COLUMNS(B2:E4))returns the last column's first value (North Q4) even if more quarters are added.- Use COUNTA if you want to count only non-empty cells.
Google Sheets
COLUMNS also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.
COLUMNS in other languages
In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.
| Language | Function name |
|---|---|
| Czech | SLOUPCE |
| Danish | KOLONNER |
| Dutch | KOLOMMEN |
| Finnish | SARAKKEET |
| French | COLONNES |
| German | SPALTEN |
| Hungarian | OSZLOPOK |
| Italian | COLONNE |
| Norwegian (Bokmål) | KOLONNER |
| Polish | LICZBA.KOLUMN |
| Portuguese (Brazil) | COLS |
| Portuguese (Portugal) | COLS |
| Russian | ЧИСЛСТОЛБ |
| Spanish | COLUMNAS |
| Swedish | KOLUMNER |
| Turkish | SÜTUNSAY |
Recipes that use COLUMNS
- How to reverse a list in Excel
- How to transpose rows and columns in Excel
- How to unpivot data in Excel with Power Query