How to Return the Column Number of Match in Excel – 5 Methods

Consider the following dataset.

Dataset-1

We have used Microsoft Excel 365 version here, you can use any other versions according to your convenience.


Method-1 – Using the MATCH Function to Return Column Number of Match

Steps:

  • Enter this formula in F5.

=MATCH(E5,$4:$4,0)

E5 cell refers to the Sales, and $4:$4 indicates Row Number 4; 0 (match_type argument) represents the Exact match criteria.
Note: Provide an Absolute Cell Reference for the first C5  by pressing F4.

Excel Return Column Number of Match Using MATCH Function

Excel Return Column Number of Match Using MATCH Function

This is the output.

Using MATCH Function

Read More: Column Letter to Number Converter in Excel


Method-2 – Return a Matched Column Number with the COLUMN Function 

Steps:

  • Enter this formula in F5.

=COLUMN(C4)

The COLUMN function takes the reference argument and returns the column number of a reference cell. Here, C4 is the reference argument (Sales).

Excel Return Column Number of Match Using COLUMN Function

  • Enter the COLUMN function and B4 as cell reference for the Name.

Excel Return Column Number of Match Using COLUMN Function

This is the output.

Using COLUMN Function

Read More: How to Change Column Name from ABC to 1 2 3 in Excel


Method 3 –Using the SUBSTITUTE Function to Obtain a Column Letter from a Specific Cell

Steps:

  • Enter this formula in F5.

=SUBSTITUTE(ADDRESS(1,COLUMN(C4),4),"1","")

C4 refers to Sales.

Formula Breakdown:

  • COLUMN(C4) → returns the column number of C4.
    • Output → 3
  • ADDRESS(1,COLUMN(C4),4) → becomes
    • ADDRESS(1,3,4) →  creates a cell reference as text. 1 is the row_number argument and 3 is the column_number argument. 4 represents the optional abs_num argument which contains the ADDRESS  function to return a Relative Reference.
    • Output → C1
  • =SUBSTITUTE(ADDRESS(1,COLUMN(C4),4),”1″,””) → becomes
    • =SUBSTITUTE(C1,”1″,””) → Replaces existing text with new text. Here, C1 refers to the text argument (Sales).  “1” is the old_text argument, and the “” refers to the new_text argument which is left blank.
    • Output → C

Excel Return Column Number of Match Using SUBSTITUTE Function

  • Repeat the process for F6.

Excel Return Column Number of Match Using SUBSTITUTE Function

This is the output.

Using SUBSTITUTE Function


Method 4 – Applying a VBA Code to Return a Matched Column Number in Excel

Step 1: Open Visual Basic Editor

  • Go to the Developer tab >> click Visual Basic.

Excel Return Column Number of Match Using VBA Code

Visual Basic Editor will open in a new window.


Step 2: Insert VBA Code

  • Choose the Sheet to insert a Module. Here, Sheet4 (VBA Code).
  • Go to the Insert tab >> select Module.

Excel Return Column Number of Match Using VBA Code

Enter the following code.

Sub FindColumnNumber()
Dim RowNumber As Long
RowNumber = Application.WorksheetFunction.Match("Sales", Sheet1.Rows(3), 0)
MsgBox "The column number is " & RowNumber
End Sub

Excel Return Column Number of Match Using VBA Code

Code Breakdown:

  • The sub-routine is given a name.
  • The variable RowNumber  is defined and the Long data type is selected.
  • The MATCH function determines the Column Number of the Sales header.
  • RowNumber stores this value.
  • the MsgBox function displays the result.

Code Explanation


Step 3: Run the VBA Code

  • Press F5.
  • In the Macros dialog box, click Run.

Excel Return Column Number of Match Using VBA Code

A window is displayed showing the Column Number.

Excel Return Column Number of Match Using VBA Code


Method 5 – Utilizing an Excel Table to Return the Column Number of Match 

This is the dataset.

Utilizing Excel Table to Return Column Number of Match

Steps:

  • In B4 >> press CTRL + T to insert an Excel Table.

Inserting Table in Excel

  • Press CTRL + SHIFT + Right Arrow (->) to select all column headers >> Press CTRL + C to copy them.

Using Keyboard shortcut to copy column names

  • Press CTRL + ALT+ V to open Paste Special >> check Values and Transpose >> Click OK.

Using Paste Special

This is the output.

GIF with steps with copy and paste as transposed values

  • Enter this formula in C17 >> drag the Fill Handle tool to copy the formula.

=MATCH(B17,Clients_List[#Headers],0)

B17 refers to the Company Name whereas Clients_List is the name of the Excel Table.

Utilizing MATCH function

  • Insert an extra Manager column and Column Numbers will change.

Excel Return Column Number of Match Using MATCH Function and Excel Table

You can also find a specific value in rows and return the column number by using a VBA code.


Return Value for a Match Column Using the INDEX and MATCH Functions 

This is the sample dataset.

Dataset 2

Steps:

  • Choose a Subject and enter the Student Name. Here, Physics and Patrick.
  • Go to C14 and enter the formula below.

=INDEX(C6:I9,MATCH(C12,B6:B9,0),MATCH(C13,C5:I5,0))

 Here, the C6:I9 range represents the marks scored by the students in the 4 Subjects.

Formula Breakdown

  • MATCH(C12, B6:B9,0) → returns the relative position of an item in an array matching the given value. Here, C12 is the lookup_value argument (Physics). B6:B9 represents the lookup_array argument that searches the match. 0 is the optional match_type argument which indicates Exact match criteria.
    • Output → 1
  • MATCH(C13, C5:I5,0) → In this formula, C13 is the Student Name PatrickC5:I5 is the array from which Patrick is matched. 0 indicates Exact match criteria.
    • Output → 4
  • =INDEX(C6:I9,MATCH(C12,B6:B9,0),MATCH(C13,C5:I5,0)) → becomes
    • =INDEX(C6:I9,1,4) → Returns a value at the intersection of a row and column in a given range. In this expression, C6:I9 is the array argument (marks scored by the students). 1 is the row_num argument (the row location). 4 is the optional column_num argument (column location).
    • Output → 49

Excel Return Column Number of Match Using INDEX and MATCH Functions

This is the output.

Excel Return Column Number of Match Using INDEX and MATCH Functions


Practice Section

Practice with this sample dataset.

Practice Section


Download Practice Workbook


Related Articles


<< Go Back to Column Number | Columns in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Eshrak Kader
Eshrak Kader

Eshrak Kader is a dedicated professional with a BSc. Degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. He boasts a rich background in Microsoft Office Suite, and over the past year, he has authored over 120 insightful articles for the ExcelDemy. Currently, Eshrak leads a team of 5 in the ExcelDemy Video project and enjoys problem-solving and making videos on Excel. Eshrak’s passion for continuous learning underscores his commitment to excellence in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo