Practice free

COLUMNS function

COLUMNS counts the columns in a range or array and returns that number. It is useful for sizing a range or checking spill output, and it counts columns only; ROWS counts rows.

Example

Read it as a sentence: count how many columns are in B1:E7, which gives 4.

Practice this in the app

Syntax

COLUMNS(array)

array (required)
A range or array.

Returns: The number of columns.

What Excel actually returns

Each formula below was run in desktop Excel. The result is exactly what the cell showed, errors included.

FormulaExcel showsCase
=COLUMNS({1,2,3;4,5,6}) 3 Array constant
=COLUMNS(5) 1 Scalar
=COLUMNS("abc") 1 Text
=COLUMNS(Items!B1:E7) 4 Range
=COLUMNS(Data!A:XFD) 16384 All columns
=COLUMNS(Data!F1) 1 Blank cell

The Items sheet these formulas read

The Data sheet these formulas read

A cell that starts with = holds that formula.

Watch out for

  • Counts columns only; ROWS counts rows.

Where it works

Excel
COLUMNS is in every version of Excel from 2007 on.
Google Sheets
Same name, same behaviour for everyday use.

Part of Lookup and reference functions. Every result on this page was measured in desktop Excel, build 16.0.20527. Last updated .