How to Check if Two Values Are in the Same Column in Excel
Question details
The user needs a formula to verify if two specific reference values (e.g., in cells F3 and F4) simultaneously exist within the identical column of a designated data range (e.g., the 'Dropdown list' worksheet).

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Validating data or cross-referencing to ensure two items share the same category or column classification within a reference table.
- Observed behavior
- A logical test is needed that returns 'yes' if both values are located in the same column across a multiple-column range, and 'no' if they do not.
Verify that your lookup values in F3 and F4 do not contain hidden spaces, and ensure your reference range in the 'Dropdown list' sheet is accurately defined without merged cells blocking the columns.
Use COUNTIF with Logical Operators (Recommended)
Use a combination of IF, OR, AND, and COUNTIF to evaluate each target column individually. This approach is highly structured and easy to read.
This formula checks each column (e.g., N through R) independently. If both F3 and F4 are found in column N, the AND statement returns TRUE. The OR statement wraps all the column checks, returning TRUE if any single column contains both values.
Click on the cell where you want the 'yes' or 'no' result to be displayed.
Click the formula bar and enter: =IF(OR(AND(COUNTIF('Dropdown list'!N:N,F3)>0,COUNTIF('Dropdown list'!N:N,F4)>0),AND(COUNTIF('Dropdown list'!O:O,F3)>0,COUNTIF('Dropdown list'!O:O,F4)>0),AND(COUNTIF('Dropdown list'!P:P,F3)>0,COUNTIF('Dropdown list'!P:P,F4)>0),AND(COUNTIF('Dropdown list'!Q:Q,F3)>0,COUNTIF('Dropdown list'!Q:Q,F4)>0),AND(COUNTIF('Dropdown list'!R:R,F3)>0,COUNTIF('Dropdown list'!R:R,F4)>0)),"yes","no")
Press the Enter key. The cell will display 'yes' if both values share a column, or 'no' otherwise.

Return the Specific Column Letter
Modify the COUNTIF logic to output the exact column letter where the match was found, rather than a generic yes/no.
Use MMULT for a Compact Array Formula
If you are working with a defined 2D range and your values are unique, you can use the MMULT array formula for a much shorter solution.
Effortlessly Manage Complex Formulas with WPS Spreadsheet
WPS Spreadsheet provides powerful support for advanced data analysis and nested logic functions like COUNTIF, IF, and MMULT. Cross-reference datasets, analyze extensive lists, and track specific values easily with its rich feature set.
- 1. Download and install WPS Office: Visit the official WPS website, download the free suite, and install it on your device.
- 2. Open your workbook: Launch WPS Spreadsheet and open the .xlsx file containing your Dropdown list data.
- 3. Use the Formula tools: Go to the 'Formulas' tab on the top ribbon and use 'Insert Function' to easily build your COUNTIF logic.
- 4. Save your work seamlessly: Save your file; WPS natively uses the .xlsx format, ensuring perfect compatibility if shared with Microsoft Excel users.

Frequently Asked Questions
Can I check if values are in the same column across an entire sheet instead of specific columns?
Yes, but using COUNTIF for thousands of columns via nested IFs is not practical. For dynamic arrays, you can use the BYCOL function combined with LAMBDA (if your spreadsheet version supports it) to iterate over all columns in an array efficiently.
How do I ignore blank cells when checking values?
You can wrap your main formula inside an initial IF statement that checks for blanks. For example, use =IF(OR(ISBLANK(F3), ISBLANK(F4)), "Missing input", [Your COUNTIF formula here]) to prevent the formula from executing when the lookup cells are empty.
Will this COUNTIF formula differentiate between upper and lower case letters?
No. The COUNTIF function is not case-sensitive. To strictly match cases, you must replace COUNTIF with an array formula utilizing the EXACT function paired with SUMPRODUCT.




