Function · Lookup
Excel COLUMNS function
The Excel COLUMNS function counts the columns in a reference. The five state codes laid across A1:E1 occupy 5 columns.
Syntax =COLUMNS(array)
=COLUMNS(A1:E1)Arguments
| Name | Required | What to pass |
|---|---|---|
| array | Required | The range or array. Empty columns count. |
Examples
How wide the state header is
=COLUMNS(A1:E1)Result 5
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | CA | FL | MA | NY | TX |
| 2 | 5 |
COLUMNS counts columns. A1:E1 runs from CA through TX, five labels, so the result is 5. An empty column inside the range still counts. The function is the width of the reference, not a count of headers that contain text.
HLOOKUP’s row index is easier to check when COLUMNS of the table matches the width you think you searched. ROW and COLUMN return one coordinate. ROWS and COLUMNS return a size.