COLUMNS Function (Gnumeric)
Learn the COLUMNS function in Gnumeric: Returns the number of columns in an array or reference.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
COLUMNS returns the number of columns spanned by a reference or array. It measures width regardless of how many cells contain data. Use it to check a block’s shape, create an expanding horizontal counter or calculate with a fixed number of column positions.
Syntax and range shape
=COLUMNS(reference)
reference is one required array or area. For a rectangle, count from its leftmost through rightmost column, including both endpoints. Row count does not affect the result. The output is a count, not a column letter or worksheet column position.
COLUMNS(A1:C5) is 3 because it spans A, B and C. COLUMNS(B2:E2) is 4 despite having only one row. COLUMNS(B2:B9) is 1 despite having eight rows.
Retained example
Enter the original practice data in A1:C5 as shown. The table headings below identify worksheet columns; do not insert them as a separate header row. Row 1 contains 1, 10 and apple.
| Row | A (Quantity) | B (Amount) | C (Category) |
|---|---|---|---|
| 1 | 1 | 10 | apple |
| 2 | 2 | 20 | pear |
| 3 | 3 | 30 | apple |
| 4 | 4 | 40 | pear |
| 5 | 5 | 50 | apple |
=COLUMNS(A1:C5)
The expected result is 3. The rectangle contains fifteen cell positions, but just three columns. Multiplying COLUMNS(A1:C5) by ROWS(A1:C5) gives total capacity, 3*5=15.
Deleting cell contents does not change the boundaries. Empty cells are still part of the reference. Changing A1:C5 to A1:D5 is different: it expands the width to four columns.
Worked layout check
A report reserves B2:E5 for four periods. =COLUMNS(B2:E5) gives 4. Expanding the formula to B2:F5 gives 5. This checks structure when each period occupies one column.
It does not verify that period labels exist, dates are in order or each period has a valid observation. A width check can pass while every cell is empty. Keep structural checks separate from data completeness rules.
Advanced use: expanding counter
Enter =COLUMNS($B$2:B2) in B10 and copy across through D10. The formulas become =COLUMNS($B$2:C2) and =COLUMNS($B$2:D2), giving 1, 2 and 3.
The first endpoint is fixed; the second expands to the right. This counts position relative to a chosen origin without hardcoding worksheet column numbers. Copying downward does not create that horizontal progression.
For B2:E2 containing 10, 20, 30 and 40, =SUM(B2:E2)/COLUMNS(B2:E2) gives 25. Its denominator deliberately counts four slots. If one score is blank, the width remains four, so this formula is not generally interchangeable with an average that ignores missing values.
Troubleshooting and limits
COLUMN gives a worksheet position, while COLUMNS gives a width. Supply a real reference or array rather than relying on conversion of arbitrary text or scalar values. The official contract describes an array or area, and these examples stay within that contract.
For repeated counters, inspect dollar signs and copying direction. For imported workbooks, inspect actual preserved references rather than trusting cached values. These controls cover ordinary contiguous same-sheet ranges, not multi-area or external-reference behavior.
Availability and verification
Version coverage: Gnumeric 1.12.57 has the scoped checks below. The 1.12.62 evidence is a documentation/source check dated October 14, 2026.
- Introduced: Gnumeric 0.19, documented in the official release history. This is a historical introduction record; the native controls below use 1.12.57.
- Availability: Supported in Gnumeric 1.12.62, based on the function-specific registration.
- Scope: Desktop; the fn-lookup function module must be included and enabled.
- Checked: October 14, 2026. Documentation/source check; no new native test in Gnumeric 1.12.62.
The executable contract is also present in the official Gnumeric 1.12.57 fn-lookup source. The saved source was originally retrieved on October 17, 2026 and re-inspected for this guide. The last functioning release is not established; support in a named version is not a retirement claim.
On October 17, 2026, Gnumeric ssconvert 1.12.57 recalculated a synthetic workbook in the C.UTF-8 locale. Scoped controls: =COLUMNS(A1:C5) → 3; =COLUMNS(B2:E2) → 4; =COLUMNS(B2:B9) → 1; =COLUMNS($B$2:B2) → 1; =COLUMNS($B$2:D2) → 3. These are native calculation-engine results, not GUI tests or screenshots. Other tutorial layouts and displayed outputs are independent expectations unless covered by these exact formulas. Input/output files, preserved formulas, raw values and hashes were retained. The XLSX importer logged an unused workbookProtection-element warning; changed-input controls and recorded results were checked.