Formula Errors

How to Match ZIP Codes Across Multiple Columns in Excel (Return 1 or 0)

Huma Ashraf ChHuma Ashraf Ch Oct 28, 2026 869 views

Question details

The user needs an Excel formula to check if a specific ZIP code from one sheet exists in any of three columns on another sheet, returning a 1 (found) or 0 (not found).

How to Match ZIP Codes Across Multiple Columns in Excel
Product
Excel
Device & OS
not provided
Scenario
Cross-referencing an Entrance Survey sheet against a master list of DMV ZIP codes that are distributed across three distinct columns.
Observed behavior
The standard VLOOKUP formula fails because it only searches the first column of a range, and mismatched data types between the sheets are causing false negatives.
Before you start

Verify that both sheets format the ZIP codes identically (either both as Text or both as Numbers) to prevent mismatches, especially for ZIP codes with leading zeros.

Solution 1Recommended

Use the COUNTIF Function for Exact Matches

The COUNTIF function is the most reliable and efficient way to search for an exact match across a multi-column range.

VLOOKUP and XLOOKUP are designed to search a single column or row. When you need to check if a value exists anywhere within a broader range (like three columns), COUNTIF evaluates the entire grid at once.

By wrapping the condition in a double unary operator (--), we force Excel to convert the TRUE/FALSE result into a 1 or 0.

1
Select the target cell

Click on the first cell in your Entrance Survey sheet where you want the 1 or 0 to appear (e.g., D2).

2
Enter the COUNTIF formula

Type the formula: =--(COUNTIF('DMV Zips'!$A$1:$C$287, C2)>0) and press Enter.

3
Apply to all rows

Click the small square at the bottom right of the target cell and drag it down to fill the formula for all remaining rows.

Use the COUNTIF Function for Exact Matches
Understanding the formula: COUNTIF counts how many times the ZIP code in C2 appears in the range A1:C287. The '>0' turns that count into TRUE/FALSE, and the '--' converts TRUE to 1 and FALSE to 0.
Solve it with WPS Office

Analyze Cross-Sheet Data Easily with WPS Spreadsheet

WPS Spreadsheet fully supports advanced mathematical, logical, and lookup functions like COUNTIF, XLOOKUP, and array formulas. Easily verify cross-column data and maintain 100% compatibility with Microsoft Excel formats.

  1. 1. Open your data: Launch WPS Spreadsheet and open your existing .xlsx workbook.
  2. 2. Format data consistently: Highlight your ZIP code columns, right-click, select 'Format Cells', and ensure both sheets are formatted as Text.
  3. 3. Enter the formula: Click your results column and input the exact COUNTIF formula: =--(COUNTIF('DMV Zips'!$A$1:$C$287, C2)>0).
  4. 4. Fill the results: Drag the fill handle to automatically apply the 1/0 flags to the rest of your survey data.
Full compatibility with Microsoft Excel (.xlsx) formulas and formattingSeamlessly evaluate multi-column ranges without performance lagBuilt-in text-to-columns and formatting tools for clean data prepLightweight, fast, and completely free to use
microsoft office alternative - wps office

Frequently Asked Questions

Why does my VLOOKUP return an error when checking multiple columns?

VLOOKUP is designed strictly to search the first leftmost column of a specified range. To search across multiple columns simultaneously, you must use alternative functions like COUNTIF, or combine INDEX and MATCH with array formulas.

How do I keep leading zeros in my ZIP codes?

By default, spreadsheet software treats numbers starting with zero as standard integers and removes the leading zero. To prevent this, select the cells, format them as 'Text' before typing or pasting your data, or apply a custom number format like '00000'.

What does the double dash (--) mean in an Excel formula?

The double dash is known as a double unary operator. It forces logical boolean values (TRUE or FALSE) to convert into their numeric equivalents (1 or 0), making it extremely useful when you need a binary output for statistical analysis.