Finding the column number of a matching value in Excel can be a tedious task, especially when working with large datasets. However, there are several ways to accomplish this task easily and efficiently. In this article, we will explore different methods to find the column number of a matching value in Excel.
Why is it important to find the column number of a matching value?
Before we dive into the methods, it's essential to understand why finding the column number of a matching value is important. In many cases, you may need to perform actions based on the column number, such as copying data, applying formulas, or formatting cells. Knowing the column number can help you to write more efficient formulas, automate tasks, and reduce errors.
Method 1: Using the MATCH
function
The MATCH
function is one of the most straightforward ways to find the column number of a matching value. The syntax for the MATCH
function is:
MATCH(lookup_value, lookup_array, [match_type])
Where:
lookup_value
is the value you want to findlookup_array
is the range of cells you want to search[match_type]
is an optional argument that specifies the type of match ( exact, approximate, or wildcard)
For example, suppose you have a table with headers in the first row, and you want to find the column number of the header "Sales".
Header 1 | Header 2 | Sales | Header 4 |
---|---|---|---|
You can use the following formula:
=MATCH("Sales", A1:D1, 0)
This formula returns the column number of the header "Sales", which is 3.

Method 2: Using the INDEX
and MATCH
functions
The INDEX
and MATCH
functions can be used together to find the column number of a matching value. The syntax for the INDEX
function is:
INDEX(array, row_num, column_num)
Where:
array
is the range of cells you want to searchrow_num
is the row number you want to returncolumn_num
is the column number you want to return
For example, suppose you have a table with headers in the first row, and you want to find the column number of the header "Sales".
Header 1 | Header 2 | Sales | Header 4 |
---|---|---|---|
You can use the following formula:
=INDEX(A1:D1, 1, MATCH("Sales", A1:D1, 0))
This formula returns the value in the cell at the intersection of the first row and the column number of the header "Sales".

Method 3: Using VBA
If you prefer to use VBA, you can write a macro to find the column number of a matching value. Here is an example code:
Sub FindColumnNumber()
Dim ws As Worksheet
Dim headerRow As Range
Dim headerCell As Range
Dim columnName As String
Dim columnNumber As Integer
Set ws = ThisWorkbook.ActiveSheet
Set headerRow = ws.Range("A1:D1")
columnName = "Sales"
For Each headerCell In headerRow.Cells
If headerCell.Value = columnName Then
columnNumber = headerCell.Column
Exit For
End If
Next headerCell
MsgBox "The column number of " & columnName & " is " & columnNumber
End Sub
This macro finds the column number of the header "Sales" in the range A1:D1 and displays the result in a message box.

Method 4: Using Power Query
Power Query is a powerful tool in Excel that allows you to manipulate and analyze data. You can use Power Query to find the column number of a matching value.
For example, suppose you have a table with headers in the first row, and you want to find the column number of the header "Sales".
Header 1 | Header 2 | Sales | Header 4 |
---|---|---|---|
You can use the following Power Query formula:
= Table.ColumnNames(#"Table1"){List.PositionOf(#"Table1"[#Headers], "Sales")}
This formula returns the column number of the header "Sales".

Conclusion
Finding the column number of a matching value in Excel can be a challenging task, but there are several methods to accomplish it. In this article, we explored four methods: using the MATCH
function, using the INDEX
and MATCH
functions, using VBA, and using Power Query. Each method has its advantages and disadvantages, and the choice of method depends on your specific needs and preferences.
Whether you are a beginner or an advanced user, finding the column number of a matching value is an essential skill to have in your Excel toolkit.
Gallery of Finding Column Number Methods
Methods for Finding Column Number










FAQ
Q: How do I find the column number of a matching value in Excel?
A: You can use the MATCH
function, the INDEX
and MATCH
functions, VBA, or Power Query to find the column number of a matching value.
Q: What is the syntax for the MATCH
function?
A: The syntax for the MATCH
function is MATCH(lookup_value, lookup_array, [match_type])
.
Q: How do I use Power Query to find the column number of a matching value?
A: You can use the Table.ColumnNames
function and the List.PositionOf
function to find the column number of a matching value.
Q: Can I use VBA to find the column number of a matching value? A: Yes, you can use VBA to find the column number of a matching value by writing a macro.