Lookup & reference function

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)
ArgumentWhat it means
arrayRequiredA 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?

B6fx=COLUMNS(B1:E4)
ABCDE
1RegionQ1Q2Q3Q4
2North12500142001390016100
3South9800104001125012030
4East7600815089009420
5
64

Result: 4

B to E is four columns.

2Number of data cells in a block

B6fx=ROWS(B2:E4) * COLUMNS(B2:E4)
ABCDE
1RegionQ1Q2Q3Q4
2North12500142001390016100
3South9800104001125012030
4East7600815089009420
5
612

Result: 12

3 regions times 4 quarters gives 12 figures. Unlike COUNT, this counts blank cells too.

3Width of an array constant

A1fx=COLUMNS({10,20,30;40,50,60})
A
13

Result: 3

Commas separate columns and semicolons separate rows, so this array is 3 columns wide.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 15 KB

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.

LanguageFunction name
CzechSLOUPCE
DanishKOLONNER
DutchKOLOMMEN
FinnishSARAKKEET
FrenchCOLONNES
GermanSPALTEN
HungarianOSZLOPOK
ItalianCOLONNE
Norwegian (Bokmål)KOLONNER
PolishLICZBA.KOLUMN
Portuguese (Brazil)COLS
Portuguese (Portugal)COLS
RussianЧИСЛСТОЛБ
SpanishCOLUMNAS
SwedishKOLUMNER
TurkishSÜTUNSAY

Recipes that use COLUMNS