# 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.

### Excel Function Syntax

=COLUMN(*reference*)

### Arguments

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

### Comments

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.

#### Table of Contents

- 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. 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:

### 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.

## 2. 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:

### 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.

## 3. 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.

## 4. 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:

### 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.

## 5. 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.

## 6. 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.

## 7. 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)

## 8. 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.

### 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.

## 9. 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

The following 62 articles have formulas containing the COLUMN function.

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 […]

Brad asks: I'm trying to use your formulas to create my own bill reminder sheet. I envision a workbook where […]

In this example we are going to use two lists with identical columns, shown in the image above. It is […]

Use the following formula to convert a column number to a column letter: =LEFT(ADDRESS(1, B3, 4), MATCH(B3, {1; 27; 703})) […]

Question: I have a question that I can’t seem to find an answer to: I want to make a full […]

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

I will demonstrate three different techniques to build monthly date ranges in this article. Two of these techniques are easy because they […]

I will demonstrate three different methods to build quarterly date ranges in this article. The two first methods have a […]

The image above shows an array formula in cell B3 that calculates numbers based on the numerical ranges in cell […]

This article demonstrates a scoreboard, displayed to the left, that sorts contestants based on total scores and refreshes instantly each […]

This workbook contains two worksheets, one worksheet shows a calendar and the other worksheet is used to store events. The […]

Anura asks: Is it possible to extend this by matching items that meet a criteria? I have a list of […]

Question: I have a list and I want to filter out all rows that have a value (Column C) that […]

This article describes how to filter duplicate rows with the use of a formula. It is, in fact, an array […]

Question: How to filter rows using dates? Answer: In this post I will describe how to: Filter rows using array […]

Table of Contents Extract negative values and adjacent cells (array formula) Extract negative values and adjacent cells (Excel Filter) Array […]

This article demonstrates an array formula that returns the table header based on a condition. For example, in cell C8 […]

In a previous article "Automatically filter unique row records from multiple columns", I presented a solution to filter out unique […]

The formula in cell B10 extracts unique distinct values from cell range B2:d4 that contains the string specified in cell […]

The array formula in cell B10 extracts unique distinct values from cell range B2:D4 that begins with a given condition […]

The image above shows an array formula in cell B12 that extracts values shared by cell range B2:D4 (One) and […]

The array formula in cell B10 extracts duplicate values from cell range B2:D4 if they begin with the condition specified […]

The array formula in cell B10 extracts duplicate values from cell range B2:D4 if they contain string specified in cell […]

Murlidhar asks: How do I search text in cell and use a date range to filter records? i.e st.Dt D1 […]

Table of contents Filter unique distinct row records Filter unique distinct row records but not blanks Filter unique distinct row […]

Sean asks: If Tea and Coffee has Americano,it will only return Americano once and not twice. I am looking for a […]

EEK asks: I am looking for the same formula on this page, but targeting a range of MxN (spanning multiple […]

Unique values are values occurring only once in cell range. This is what I am going to demonstrate in this blog […]

The formulas above extracts values that exists only in one or the other cell range, if you are looking for […]

This formula returns multiple values even if they are arranged differently or have minor misspellings compared to the lookup value.

The above picture shows you two formulas that extract names (column B) and date ranges (column C and D) based […]

Question: How to extract email addresses from this sheet? (See pic below) Answer: It depends on how the emails are […]

This article demonstrates two formulas, the first formula counts items by quarter and the second formula extracts the corresponding items […]

This article demonstrates formulas that will return the largest and smallest numbers, the corresponding column headers, the cell addresses, and […]

I will in this article demonstrate three different techniques to sort a data set in Excel. The first method sorts […]

This article demonstrates how to insert and use a scroll bar (Form Control) in Excel. It allows the user to […]

This article demonstrates formulas that let you perform lookups using two or more conditions. The image above shows two conditions […]

This article demonstrates a formula that extracts unique distinct records/rows for a given month specified in cell C2, see the […]

This article demonstrates a formula that allows you to search a data set using any number of conditions, however, one […]

This article demonstrates how to extract records/rows based on two conditions applied to two different columns, you can easily extend […]

Question: I'm using excel 2003. This is my problem.Sheet 1 COL A contains fruits, col B to H contains there […]

This article demonstrates techniques on how to merge or combine two data sets using a condition. The top left data […]

This article demonstrates formulas that rearrange values in a cell range to a single column. Table of Contents Rearrange cells […]

In this blog post I will provide two solutions on how to remove blank cells and a solution on how […]

This article demonstrates how to filter records occurring in only one out of two Excel defined tables. It also shows […]

Mr.Excel had a "challenge of the month" June/July 2008 about Wildcard VLOOKUP: "The data in column A contains a series […]

This article demonstrates a few different formulas that extract values from the table column header names and the right-most column. […]

Below is an excel table containing recurring expenses and corresponding amounts, dates and recurring intervals. An excel table allows you to […]

Question: How do I identify rows that have a specific cell value in an Excel defined table? Array formula in […]

I will in this article demonstrate how to search a table for a date based on a condition and then […]

Question: Hi, The formula here works great but I can't figure out how to change it to work with data […]

The formula in cell B8 extracts a list sorted based on frequency. Array formula in B8: =TEXTJOIN("", TRUE, IF(MIN(IF((MAX(IF(COUNTIF($B$7:B7, $B$2:$E$5)=0, […]

In this article, I will demonstrate two techniques for counting per row. The first example is simple and straightforward. The […]

This article demonstrates a formula that sorts items arranged horizontally based on the adjacent numbers, every other column contains a […]

This article describes a formula that sorts values arranged in a column from A to z by every other value. […]

This blog article describes how to split strings in a cell with space as a delimiting character, like Text to […]

Mark G asks in Create a random playlist in excel: Can this example be modified to create a true round-robin […]

This article demonstrates how to sort a table based on count meaning the formula counts each record and returns a […]

This article demonstrates a formula that lets you extract non-empty values across columns based on a condition. The image above […]

This article demonstrates three different ways to filter a data set if a value contains a specific string and if […]

### 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