# How to use the COLUMN function

The COLUMN function returns the column number of the top-left cell of a cell reference. If the argument is not entered the column number of the cell the formula is entered in is returned, see cell B6 in the picture above.

#### Table of Contents

- COLUMN Function Syntax
- COLUMN Function Arguments
- COLUMN Function Example
- How to convert a column number to a column letter?
- How to convert a column letter to a column number?
- How can the Column function return an array?
- Column function and VLOOKUP
- Column function of other functions
- Column function with a cell ref to a cell range?
- Create a horizontal sequence
- Column function and SMALL function
- How to use the Column function in VBA
- Get Excel file

## 1. COLUMN Function Syntax

COLUMN(*reference*)

## 2. COLUMN Function Arguments

reference |
Optional. The cell reference for which you want to extract the column number from. |

The COLUMN function allows you to also return an array of column numbers if you enter the formula as an array formula and use a cell range containing multiple columns.

You can not use multiple cell references in the COLUMN function.

## 3. COLUMN Function example

Formula in cell B3:

Column letter V corresponds to column number 22. A is 1, B is 2, and so on.

## 4. How to convert a column number to a column letter?

The formula in cell C3 calculates the column letter from a column number. Column number 1 is column A, column 2 is B, and so on. See the image above.

Formula in cell C3:

### 4.1 Explaining formula in cell C3

#### Step 1 - Calculate cell address

TheÂ ADDRESS function returns the address of a specific cell, you need to provide a row and column number.

ADDRESS(*row_num*,Â *column_num*, [*abs_num*], [*a1*], [*sheet_text*])

ADDRESS(1,B3,4,1)

becomes

ADDRESS(1,22,4,1)

and returns "V1".

#### Step 2 - Calculate number of characters in cell address

The LEN function calculates the number of characters in a given string.

LEN(ADDRESS(1,B3,4,1))-1

becomes

LEN("V1")-1

becomes

2-1 equals 1.

#### Step 3 - Extract column letter from cell address

TheÂ LEFT functionÂ extracts a specific number of characters always starting from the left.

LEFT(ADDRESS(1,B3,4,1), LEN(ADDRESS(1,B3,4,1))-1)

becomes

LEFT("V1", 1)

and returns "V" in cell C3.

## 5. How to convert a column letter to a column number?

The formula in cell C3 calculates the column number from a column letter. Column number 1 is column A, column 2 is B, and so on. See the image above.

Formula in cell C3:

### 5.1 Explaining formula in cell C3

#### Step 1 - Concatenate strings

The ampersand character lets you concatenate values.

B3&1

becomes

"V"&1

and returns "V1".

#### Step 2 - Create cell reference

The INDIRECT function returns the cell reference based on a text string.

INDIRECT(B3&1)

becomes

INDIRECT("V1")

and returns cell reference V1.

#### Step 3 - Calculate column number

COLUMN(INDIRECT(B3&1))

becomes

COLUMN(V1)

and returns 22 in cell C3.

## 6. How can the COLUMN function return an array?

The COLUMN function calculates the column number from a cell reference, the column function returns an array of numbers if the cell reference points to a cell range that has multiple columns.

Formula in cell B3:

The formula in cell B3 returns a horizontal array of numbers from 1 to 3 representing the column numbers of cells A1, B1, and C1. Column letter A is 1, column 2 is B, and so on.

You need to enter this formula in cell B3 as an array formula if you own an earlier Excel version than Excel 365.

## 7. COLUMN function and VLOOKUP

The formula in cell C3 combines the VLOOKUP and the COLUMN functions to get all values from the same row if the lookup value matches the leftmost value in the table array.

Formula in cell B3:

### 7.1 Explaining formula in cell C10

#### Step 1 - Calculate column number

The cell reference (B1) changes when you copy the cell and paste it to adjacent cells. This makes the COLUMN function return a different value in each cell.

COLUMN(B1) returns 2.

#### Step 2 - Evaluate VLOOKUP function

The VLOOKUP function lets you search the leftmost column for a value and return another value on the same row in a column you specify.

VLOOKUP(*lookup_value*, *table_array*, *col_index_num*, [*range_lookup*])

The third argument lets you choose which column to fetch a value from, this allows us to get all values from the same row when we copy the cell and paste it to adjacent cells.

VLOOKUP($B10,$B$3:$F$7,COLUMN(B1))

becomes

VLOOKUP($B10,$B$3:$F$7, 2)

and returns "ASD" in cell C10.

## 8. COLUMN function of other columns

The COLUMN function accepts no arguments at all, this will return the column number of the cell that the function is entered in.

Formula in cell B3:

The formula above does not change when you copy the cell and paste it to adjacent cells, however, the output is different. Cell C3 is the third column and therefore 3 is returned.

You can also use a cell reference to any other column or columns, see the formula below.

Formula in cell B6:

This formula returns the column number of cell K1 which is the argument used in this example. The cell reference is a relative cell reference meaning it changes when you copy the cell and pastes it to adjacent cells, see cell range C6:D6 in the image above.

The formula below returns an array of numbers 11, 12, and 13. They correspond to the cells in cell range K1:M1 and represent their column numbers.

Formula:

You need to enter this formula as an array formula in order to see all numbers in the array unless you are using Excel 365. Note that the array is a horizontal array with the same size as there are cells in the supplied cell range.

## 9. COLUMN function with a cell ref to a cell range?

The COLUMN function repeats the array of numbers if entered in a cell range.

Array formula in cell B3:

Note, the formula is entered as a regular formula if your Excel version is 365.

## 10. Create a horizontal sequence

The COLUMN function can create a sequence of numbers that can be useful both in formulas and on a worksheet.

Formula in cell B3:

The formula above creates a horizontal sequence from 1 to n or as far as you copy the formula.

Formula in cell B6:

The formula in cell B6 creates a horizontal sequence containing odd numbers from 1 to n. Copy cell B6 and paste to adjacent cells on the same row as far as needed.

Formula in cell B9:

The formula in cell B9 creates a horizontal sequence containing odd numbers from 1 to n.

Note, relative cell references and the COLUMN function are sensitive to inserting rows and columns. The formula will break if you insert a column or row before the formula.

Use the COLUMNS function with a cell reference containing both an absolute and relative cell reference to solve this problem.

=COLUMNS($A$1:A1)

## 11. COLUMN function and SMALL function

The COLUMN function combined with the SMALL function can extract and sort numbers from a cell range or array.

Formula in cell B8:

This is a regular formula.

### 11.1 Explaining formula in cell B8

#### Step 1 - Calculate sequence number

COLUMN(A1) returns 1.

#### Step 2 - Evaluate SMALL function

The SMALL function returns the k-th smallest value from a group of numbers. The first argument is a cell range or array that you want to find the k-th smallest number from.

The second and last argument is k which is a number from 1 up to the number of values you have in the first argument.

SMALL(*array*,Â *k*)

SMALL($B$3:$B$5, COLUMN(A1))

becomes

SMALL($B$3:$B$5, 1)

becomes

SMALL({5; -2; 3}, {1})

and returns -2.

## 12. How to use the COLUMN function in VBA?

The COLUMN function does not exist in the WorksheetFunction object. You can use the RANGE.COLUMN property to achieve the same thing.

The macro below saves the column number from cell B3 to cell B3. Column B is the second column.

Sub Macro1() Range("B3") = Range("B3").Column End Sub

### 'COLUMN' function examples

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

Josh asks: now if i only knew how to apply these dependent dropdown selections to a filter, i'd be set. […]

Rodney Schmidt asks: I am a convenience store owner that is looking to make a spreadsheet formula. I want this […]

### Functions in 'Lookup and reference' category

The COLUMN 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