## How to use the COLUMNS function

**What is the COLUMNS function?**

The COLUMNS function allows you to calculate the number of columns in a cell range or array.

**What is the difference between the COLUMN function and the COLUMNS function?**

The difference between the column function and the columns function in Excel is that the column function returns the COLUMN number of a single cell reference, while the COLUMNS function returns the number of columns in an array or a range of cells.

**What other functions performs counting like the COLUMNS function?**

COLUMNS counts columns in a cell range.

COUNT counts numbers in a cell range.

COUNTA counts not empty cells in a cell range.

COUNTBLANK counts empty cells in a cell range.

COUNTIF counts cells based on a specific condition.

COUNTIFS counts cells based on specific criteria.

#### Table of Contents

## 1. COLUMNS Function Syntax

COLUMNS(*array*)

## 2. COLUMNS Function Arguments

array |
Required. A cell range for which you want to determine the number of columns. |

## 3. COLUMNS Function example

The example above shows a formula that counts the number of columns in cell range C2:J2.

Formula in cell B6:

The number of columns in cell range C2:J2 are 8.

## 4. Count columns in an array

The COLUMNS function also calculates the number of rows in an array.

The array has four columns. An array uses delimiting values to separate columns and rows.Â They may differ between users based on their regional settings.

The formula above uses comma as a column delimiting character and semicolon as a row delimiting character.

83,89,63,81;

54,68,45,2

It is easier to see that the array actually contains four columns if I put values after a semicolon on a new row.

## 5. Count columns in a value delimited string

Cell B3 contains a text string with numbers separated by commas and semicolons. The TEXTSPLIT function splits the string into an array.

Formula in cell B6:

The array has columns and rows, the columns function counts the number of columns in the array.

### 5.1 Explaining formula

#### Step 1 - Split string into an array

The TEXTSPLIT function splits a string into an array based on delimiting values.

Function syntax: TEXTSPLIT(Input_Text, col_delimiter, [row_delimiter], [Ignore_Empty])

TEXTSPLIT(B3,",",";")

#### Step 2 - Count columns in the array

COLUMNS(TEXTSPLIT(B3,",",";"))

## 6. Count columns in multiple cell ranges

This example demonstrates how to count columns in an horizontal array based on different cell ranges.

Formula in cell B12:

The HSTACK function is a new Excel 365 function that stacks cell ranges horizontally.

### 6.1 Explaining formula

#### Step 1 - Join cell ranges horizontally

The HSTACK function combines cell ranges or arrays. Joins data to the first blank cell to the right of a cell range or array (horizontal stacking)

Function syntax: HSTACK(array1,[array2],...)

HSTACK(C2:J2,C5:F5,C8:G8)

#### Step 2 - Count columns

The COLUMNS function calculates the number of columns in a cell range.

Function syntax: COLUMNS(array)

COLUMNS(HSTACK(C2:J2,C5:F5,C8:G8))

## 7. Count columns in multiple Excel Tables

Formula in cell B8:

### 7.1 Explaining formula

#### Step 1 - Join Excel Tables horizontally

The HSTACK function combines cell ranges or arrays. Joins data to the first blank cell to the right of a cell range or array (horizontal stacking)

Function syntax: HSTACK(array1,[array2],...)

HSTACK(Table1, Table2)

#### Step 2 - Count columns

The COLUMNS function calculates the number of columns in a cell range.

Function syntax: COLUMNS(array)

COLUMNS(HSTACK(Table1, Table2))

Useful links

COLUMNS function - Microsoft

COLUMNS function

### 'COLUMNS' function examples

This post explains how to lookup a value and return multiple values. No array formula required.

This article describes a formula that counts values in two columns if they are duplicates on the same row. What's […]

Question: I am trying to create an excel spreadsheet that has a date range. Example: Cell A1 1/4/2009-1/10/2009 Cell B1 […]

### Functions in 'Lookup and reference' category

The COLUMNS function function is one of many functions in the 'Lookup and reference' category.

## How to comment

How to add a formula to your comment<code>Insert your formula here.</code>

Convert less than and larger than signsUse html character entities instead of less than and larger than signs.

< becomes < and > becomes >

How to add VBA code to your comment[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

How to add a picture to your comment:Upload picture to postimage.org or imgur

Paste image link to your comment.

Contact OscarYou can contact me through this contact form