Documentation/Calc Functions/COLUMNS

    From The Document Foundation Wiki
    Other languages:


    Function name:

    COLUMNS

    Category:

    Spreadsheet

    Summary:

    Determines the number of columns in the given reference to a single cell or to a range of cells.

    Syntax:

    COLUMNS(Array)

    Returns:

    Returns an integer in the range 0 to 1024 (inclusive) which is the count of the columns in the cell(s) specified in the argument.

    • If the Array argument is omitted, then COLUMNS returns 0.
    • If the Array argument refers to a single cell, then COLUMNS returns 1.
    • If the Array argument refers to a rectangular cell range, then COLUMNS returns the number of columns in the range.

    Arguments:

    Array is a specific cell reference (for example, "$Sheet1.A1"), a specific cell range (for example, "$Sheet1.$C$28:$H$29"), the name of a named or database range, or a constant array (for example, "{1, 3, 5, 7}").

    • If Array is omitted, the value 0 is returned.
    • If Array is not a valid reference to a single cell or a single rectangular cell range, then COLUMNS reports a parameter list error (Err:504). COLUMNS does not process references that comprise multiple cell ranges.

    Additional details:

    • COLUMNS counts columns that have been hidden.
    • The value returned by COLUMNS is not dependent on the contents of the cells in a referenced cell area.

    Examples:

    Formula Description Returns
    =COLUMNS() Here the argument is omitted and so the function returns the value 0. 0
    =COLUMNS(D8) Here the argument comprises a reference to a single cell and so the function returns the value 1. 1
    =COLUMNS(A1:A1000) Here the argument comprises a reference to a range of cells within a single column and so the function returns the value 1. 1
    =COLUMNS($Sheet2.B4:G15) Here the argument comprises a reference to a range of cells straddling six columns and so the function returns the value 6. 6
    =COLUMNS(myArea) where the named range myArea covers the cell range C1:D4. Here the argument comprises a reference to a range of cells straddling two columns and so the function returns the value 2. 2
    =COLUMNS({10, 20, 30; 40, 50, 60}) Note: In the English(USA) locale, the comma is a column separator and the semicolon is a row separator. Here the argument comprises a constant array with two rows and three columns, and so the value 3 is returned. 3

    Related LibreOffice functions:

    COLUMN

    ROWS

    ODF standard:

    Section 6.13.5, part 2

    Related (or similar) Excel functions:

    COLUMNS