How to Xlookup Match Any Column in Excel

Learn multiple Excel methods to XLOOKUP and match any column in a dataset with step-by-step examples and practical applications.

excelformulaspreadsheettutorial
14 min read • Last updated: 7/2/2025

How to Xlookup Match Any Column in Excel

Why This Task Matters in Excel

Matching “any” column is one of those deceptively simple-sounding requests that appears in almost every department and industry. Imagine you keep a matrix in which each row is a customer and each column is a product they purchased. Your manager asks, “Find which customer bought Product X, and tell me the purchase date.” Sometimes the target value lives in column C, sometimes in column H, and next month it might move again when new products are inserted. In other words, the lookup position is not fixed.

Traditional lookup functions such as VLOOKUP work only when the lookup column is on the far left. INDEX + MATCH can search to the left or right, but you must still know exactly which column to interrogate. When the value could be in any column, you would need helper rows or an unwieldy set of nested IFs. XLOOKUP, along with dynamic-array helpers like CHOOSECOLS, CHOOSEROWS, HSTACK, and XMATCH, removes those constraints. These functions allow you to build one self-contained formula that:

  • Scans every column (or a subset you name)
  • Returns the first match, last match, or even all matches that meet the criteria
  • Spills results automatically without needing Ctrl + Shift + Enter
  • Adapts if you insert or reorder columns

From a business perspective this agility saves hours of manual hunting, eliminates hidden errors, and enables automated dashboards. Analysts in finance can instantly find which account a GL code sits in; HR teams can search staff skills no matter which certification column it is stored in; supply-chain specialists can locate a SKU in multidimensional inventory tables.

Finally, “matching any column” is a foundational skill that unlocks pivot-quality analysis without the learning curve of pivot tables. Once you master it, you are only one step away from multi-criteria lookups, live summaries with FILTER, and real-time data validation. Conversely, not knowing how to do it leads to fragile workbooks stuffed with redundant data or risky copy-paste operations that break whenever the structure changes.

Best Excel Approach

The most flexible modern method is to build a horizontal lookup array on the fly and feed it to XLOOKUP. By stacking the candidate columns inside the lookup_array argument, XLOOKUP checks them sequentially until it finds the first match, then returns data from a parallel return_array. The essential ingredients are:

  1. The value you are looking for (lookup_value)
  2. A constructed 1-dimensional lookup array containing every possible column to search
  3. A constructed return array that lines up position-for-position with the lookup array
  4. Optional arguments for “not found” messaging, match mode (exact, wildcard), and search mode (first, last)

Syntax pattern:

=XLOOKUP( lookup_value ,
          CHOOSE( {1,2,3}, column1 , column2 , column3 ),   -- lookup_array
          CHOOSE( {1,2,3}, return1 , return2 , return3 ),   -- return_array
          "Not found" ,
          0 ,                                               -- exact match
          1 )                                               -- search first to last

Why this is best:

  • It works in a single cell; no helper ranges are needed.
  • The lookup columns may sit anywhere in the sheet, even on different worksheets if you wrap them inside CHOOSE.
  • You may mix data types—numbers, text, dates—in the same lookup array.
  • Dynamic arrays spill automatically if you supply multiple return_array columns.

When might an alternative be better? If your dataset is very wide (hundreds of columns) but shallow (a few rows), FILTER or INDEX + XMATCH can sometimes outperform XLOOKUP in calculation speed. However, for day-to-day work under 100 000 cells, the constructed-array XLOOKUP is usually fastest to build, easiest to read, and safest to maintain.

Parameters and Inputs

To implement a “match any column” solution you need to understand each XLOOKUP argument deeply:

  • lookup_value – A single value or a spill range. Text is case-insensitive unless you add EXACT or make an array all caps for comparison.
  • lookup_array – Must evaluate to a single row or single column. When you supply multiple columns you must compress them horizontally using CHOOSE, HSTACK, or similar so that the final result is still 1-D.
  • return_array – Must be the same shape and size as lookup_array. If you want to return more than one field (e.g., spill the entire row), you can wrap your target columns in HSTACK or CHOOSE again.
  • if_not_found – Text, number, blank, or another formula. Keep it short to avoid cluttering reports.
  • match_mode – 0 (exact), ‑1 (exact or next smaller), 1 (exact or next larger), 2 (wildcards). For “any column” you almost always want 0 or 2.
  • search_mode – 1 (first to last) or ‑1 (last to first). Useful when the value can appear more than once.

Data preparation tips:

  • Trim extra spaces with TRIM or Power Query; otherwise exact matches fail.
  • Convert obvious numbers stored as text with VALUE or ‘Text to Columns’.
  • Check for merged cells—XLOOKUP cannot parse them.
  • If your lookup table comes from an external system, set the entire range as an Excel Table ([Ctrl] + T) so new columns are automatically included.

Edge cases:

  • Blank cells in the lookup array are ignored and skipped; they do not count as matches.
  • If the same value appears in multiple columns, XLOOKUP returns the first or last based on search_mode.
  • When searching across sheets, all referenced sheets must be open or links will break.

Step-by-Step Examples

Example 1: Basic Scenario

Goal: Find which month contains a sales target value and return the month name.

Sample data (range [A1:E5])

       A        B     C     D     E
1   Rep     Jan  Feb  Mar  Apr
2   Kim     15   20   18   22
3   Lee     25   30   28   35
4   Omar    12   14   15   16

Suppose Kim sets a new personal record of 22 and we want to find which month holds that number.

Step-by-step

  1. Create a named range DataRow referring to [B2:E2].
  2. Create another named range Months referring to [B1:E1].
  3. In G2 type the target value 22.
  4. In H2 enter:
=XLOOKUP( G2 , DataRow , Months , "No match" )

Explanation

  • DataRow is a 1-D horizontal array of Kim’s monthly sales.
  • XLOOKUP scans left to right until it finds 22.
  • The parallel array Months holds the labels in the exact same order.
  • Result: Apr.

Why it works
XLOOKUP only needs matching positions; the lookup and return arrays do not have to be vertical. Because DataRow and Months align perfectly, you instantly convert a numeric match into its corresponding header. A common variation is to spill the full row:

=FILTER( Months , DataRow = G2 )

but that would require Office 365. XLOOKUP remains universally readable while staying robust if columns shift.

Troubleshooting

  • If #N/A appears, confirm the input is truly numeric—not text.
  • If more than one month contains 22, add ,,-1 as the sixth argument to pick the last occurrence.

Example 2: Real-World Application

Scenario: A help-desk manager tracks ticket IDs across quarterly worksheets (Q1, Q2, Q3, Q4). Each sheet has identical structure: Column A = Ticket ID, Column B = Owner, Column C = Status. The manager wants a single search box on a dashboard sheet that returns the Status regardless of which quarter owns the ticket.

Data overview

  • Q1!A2:C500, Q2!A2:C600, Q3!A2:C450, Q4!A2:C300
  • Dashboard!B2 will store the input Ticket ID.
  • The answer should go to Dashboard!C2.

Formula in Dashboard!C2:

=XLOOKUP( B2 ,
          CHOOSE( {1,2,3,4},
                  Q1!A:A , Q2!A:A , Q3!A:A , Q4!A:A ),
          CHOOSE( {1,2,3,4},
                  Q1!C:C , Q2!C:C , Q3!C:C , Q4!C:C ),
          "Ticket not found",
          0 ,   -- exact
          1 )   -- first quarter priority

Walkthrough

  1. The CHOOSE function constructs a virtual array consisting of four whole columns side-by-side. Because CHOOSE uses hard-coded index numbers [1,2,3,4], the final result is still 1-D.
  2. The second CHOOSE creates a return array of matching size, pointing at each sheet’s Status column.
  3. If the ticket exists in more than one quarter (rare, but possible if reopened), the search_mode 1 returns the earliest quarter. Switch to ‑1 to prioritize the latest.

Benefits

  • No need for a giant consolidated table; each quarter can stay in its own sheet.
  • The formula still fits in one cell—perfect for a lightweight front-end.
  • As new quarters are added, simply extend the CHOOSE lists.

Integration tips

  • Display the controlling formula as text in a comment so colleagues can audit it.
  • Pair the dashboard with conditional formatting that highlights the search box red when no match is found (=ISNA(C2)).
  • If performance slows, replace full-column references with structured table columns, e.g., Q1_Table[Ticket ID].

Example 3: Advanced Technique

Challenge: In a 50-column lab dataset, you must find a chemical name that might appear in any column, then return not just the matching row’s date but also the column header where the match was found. Additionally, you need the formula to spill all occurrences because the same chemical can be logged multiple times on different days.

Dataset (simplified)

  • Data range [A1:AX5000] where column A = Date, columns B:AX hold chemical names.
  • Chemical to search is in cell C1.
  • Output location starts at D2.

Step 1 – Identify all rows where the chemical exists in any column:

=FILTER( A2:A5000 ,
         BYROW( B2:AX5000 ,
                LAMBDA(r, OR( r = C1 ) ) ) )

The BYROW–LAMBDA combo checks each row and returns TRUE if any element matches C1. FILTER then extracts all matching dates. But we still need the header.

Step 2 – Get the header(s) for each row:

=MAP( FILTER( B2:AX5000 ,
              BYROW( B2:AX5000 , LAMBDA(r, OR(r=C1)) ) ) ,
      LAMBDA(rowVals,
             INDEX( B1:AX1 ,
                    XMATCH( C1 , rowVals, 0 ) ) ) )

Breaking it down

  • FILTER spills only the rows that contain the target chemical.
  • MAP iterates through the spilled rows.
  • XMATCH finds the position of the chemical within each row.
  • INDEX fetches the corresponding header from [B1:AX1].

Finally, combine date and header:

=HSTACK(
   FILTER( A2:A5000 , BYROW( B2:AX5000 , LAMBDA(r, OR(r=C1))) ),
   MAP( FILTER( B2:AX5000 , BYROW( B2:AX5000 , LAMBDA(r, OR(r=C1))) ),
        LAMBDA(rowVals, INDEX( B1:AX1 , XMATCH( C1 , rowVals, 0 ))) )
)

The result is a two-column spill listing every date in column D and the precise column header with the chemical in column E.

Professional tips

  • Use LET to store the filtered block once instead of repeating it.
  • Limit column scope with CHOOSECOLS if you care only about certain test groups.
  • Benchmark with CALCULATE > Evaluate Formula to watch spill ranges grow; this helps avoid accidental 1 million-cell arrays.

Tips and Best Practices

  1. Convert to Excel Tables – Tables give each column a stable name (Sales[Apr]) so you never have to rewrite CHOOSE lists when inserting columns.
  2. Use LET for readability – Assign lookupArr and returnArr variables inside one formula to avoid typing the same ranges twice.
  3. Combine with DROP or TAKE – If new columns are always appended at the end, wrap your array in TAKE to search only the last n columns.
  4. Keep if_not_found concise – Empty string (\"\") is often better than long messages because it simplifies downstream calculations.
  5. Document assumptions – Add a cell note listing which columns participate in CHOOSE. Future editors will thank you.
  6. Benchmark on large files – Turn on “Workbook Statistics” and recalc times. If the sheet grows past 500 000 cells, explore INDEX + XMATCH or Power Query.

Common Mistakes to Avoid

  1. Mismatched Array Sizes
    If lookup_array has 10 elements but return_array has 9, XLOOKUP spills #VALUE!. Always double-check with COUNTA.

  2. Forgetting Exact vs Wildcard Mode
    By default, XLOOKUP is exact. When matching part numbers embedded in codes, set match_mode to 2 and use wildcards ("*123*") or you will miss matches.

  3. Using Full-Column References on Gigantic Sheets
    A:A on 1 million rows recalculates slowly. Restrict to the actual data range [A2:A5000] or Table columns.

  4. Ignoring Data Type Conflicts
    Numbers stored as text in one column but as numeric in another make XLOOKUP fail silently (returns “Not found”). Normalize with VALUE or format coercion.

  5. Hard-coding Sheet Names
    If your blueprint calls the sheet “2023_Q1” but next year becomes “2024_Q1”, CHOOSE will break. Store sheet names in a settings area and reference them with INDIRECT or TEXTAFTER.

Alternative Methods

MethodProsConsWhen to Use
INDEX + XMATCH (two-dimensional)Fast on very large ranges, works in legacy Excel 2019More verbose, two formulas needed to get both row and columnDatasets above 1 million cells
FILTER + BYCOL/BYROWReturns all hits, supports array formulas out of the boxRequires Office 365, spill may overwhelm sheetSituations where multiple matches matter
Power QueryHandles millions of rows, no formulas once loadedNot real-time; requires refresh; steeper learning curveETL tasks, scheduled reports
Pivot TableVisual, drag-and-drop, no formulasRefresh required, limited to aggregate summariesInteractive analysis for non-technical users
VBA UDFUltimate flexibility, custom logicRequires macro-enabled workbook, security promptsHighly bespoke matching criteria

Choose the method based on volume, Excel version, and the need for live interactivity. You can even mix methods: use Power Query to stage data, then XLOOKUP on the cleaned table for ad-hoc analysis.

FAQ

When should I use this approach?

Use XLOOKUP-match-any-column when the lookup value could sit in multiple columns and you need one cell to return the match (or associated data) without helper columns. Typical cases include transposed databases, survey scores across questions, and multi-regional SKUs stored side-by-side.

Can this work across multiple sheets?

Yes. Wrap each sheet’s column in CHOOSE or HSTACK. Just be sure all referenced workbooks are open; otherwise you get #REF!. For dozens of sheets, consider INDEX + XMATCH inside 3D references or migrate to Power Query.

What are the limitations?

XLOOKUP cannot search a true two-dimensional grid directly; you must flatten it to a single row/column. It returns only the first or last match, not every match. Finally, it is available only in Office 365 and Excel 2021 perpetual; older versions lack it.

How do I handle errors?

Return a blank with if_not_found set to \"\" to suppress #N/A. For unexpected errors, nest inside IFERROR:

=IFERROR( your-XLOOKUP-formula , "Check data" )

Diagnose with “Evaluate Formula” or wrap suspect ranges in COUNTA to ensure they contain expected values.

Does this work in older Excel versions?

No. Excel 2019 and earlier do not have XLOOKUP. Use INDEX + MATCH or the INDEX + XMATCH add-on if your organization installed the XMATCH back-port through Microsoft 365 add-ins. Otherwise, build a helper row that concatenates all columns.

What about performance with large datasets?

Keep ranges tight, avoid full-column references, leverage Tables, and offload heavy joins to Power Query. On 100 000-row datasets, XLOOKUP remains snappy (< 1 second). On multi-million-row CSVs, Power Query or a database engine is mandatory.

Conclusion

Mastering “XLOOKUP Match Any Column” equips you with a Swiss-army knife for messy, real-world spreadsheets. You can now locate data no matter where it hides, automate dashboards that survive structural changes, and slice multidimensional tables with a single elegant formula. This skill also acts as a gateway to dynamic arrays, BYROW/BYCOL patterns, and LAMBDA customization. Keep experimenting—next, try combining XLOOKUP with SEQUENCE or RANDARRAY to build interactive simulations. Your spreadsheets will be leaner, faster, and far more reliable.

We use tracking cookies to understand how you use the product and help us improve it. Please accept cookies to help us improve.