How to If Cell Is This Or That in Excel
Learn multiple Excel methods to if cell is this or that with step-by-step examples and practical applications.
How to If Cell Is This Or That in Excel
Why This Task Matters in Excel
Every day, millions of spreadsheets decide what should happen if a cell contains one value or another. These conditional decisions drive dashboards, automate financial models, flag data-entry mistakes, and trigger workflow actions. Imagine a sales tracker that labels deals as “Won” or “Lost,” a project plan that marks tasks “On Track” or “At Risk,” or an HR sheet that classifies employees as “Full-Time” or “Contractor.” All of these rely on a core concept: “If cell is this or that, then do something.”
Across industries the need is constant:
- Finance: Allocate expenses to cost centers if the department code is “FIN” or “ACC,” otherwise route to “OTH.”
- Marketing: Apply a higher commission rate if a campaign type is “Email” or “Social.”
- Operations: Send urgent restock alerts when inventory category is “Raw Material” or “Critical Component.”
- Education: Grade exams as “Pass” or “Fail” depending on whether the score meets either a numeric cutoff or a special override code.
Excel is ideal for this because it allows non-programmers to encode decision logic directly beside their data, update rules instantly, and audit the exact formula trail. Without mastering “If cell is this or that,” teams resort to manual filtering, hidden helper columns, or post-export scripts—all prone to error and delay. Conditional logic also underpins more advanced skills: dynamic array filtering, conditional formatting, and Power Query transformations. Therefore, learning robust techniques here pays dividends throughout the Excel workflow.
Best Excel Approach
The most versatile method is to combine the IF function with the OR function. IF evaluates what to return; OR lets you test multiple possibilities in one statement. Together they answer the natural-language question “If the cell is A or B, then ….”
Syntax breakdown:
=IF( OR( logical_test1 , logical_test2 , ... ) , value_if_true , value_if_false )
- logical_test1, logical_test2 … – individual comparisons that evaluate to TRUE or FALSE.
- value_if_true – returned when any OR test is TRUE.
- value_if_false – returned when all OR tests are FALSE.
Why this approach?
- Clarity: Each comparison is explicit, so audits and future edits are easy.
- Scalability: You can nest many tests or reference dynamic lists.
- Compatibility: Works the same from Excel 2007 through Microsoft 365, Windows or Mac.
- Flexibility: OR can be swapped for AND when you need “this and that” rather than “this or that.”
Alternative methods exist. The IFS function (365/2019+) lets you chain conditions without nesting, while SWITCH handles exact matches cleanly. XLOOKUP and CHOOSECOLS can also serve when the “value_if_true” needs to pick from multiple outcomes. These are covered later, but IF + OR remains the universal baseline.
Parameters and Inputs
Successful formulas rely on clean inputs:
- Reference cell(s): Usually a single cell like [A2] that holds the value you are testing, but OR lets you cite several if needed.
- Comparison values: Hard-typed strings (e.g., \"North\") or numeric thresholds (e.g., 100). For maintainability, store them in named ranges like [ValidCodes] rather than typing them directly.
- Return values: Text, numbers, dates, or more formulas. Remember that IF can return entirely different data types.
- Data types: Ensure the comparison cell truly stores what you expect—numeric values as numbers, codes as text. A hidden leading space can break an exact text match.
- Error handling: Wrap the entire formula in IFERROR when upstream data might contain #N/A or #DIV/0!.
- Case sensitivity: IF and OR ignore case, but FIND is case-sensitive, so choose the right function accordingly.
- Blank cells: Decide whether a blank should be considered “this,” “that,” or neither; explicitly test with =\"\" if required.
Edge case rules:
- Trailing spaces in text trigger FALSE; use TRIM on imported data.
- Mixed data types (e.g., \"123\" stored as text) produce FALSE when treating \"123\" as a number. You can coerce with VALUE or prepend a zero.
- Locale differences affect decimal separators and list-separator characters; formulas shown use commas, so swap for semicolons if your regional setting does.
Step-by-Step Examples
Example 1: Basic Scenario – Flagging “North” or “South”
Suppose you have a list of regional codes in column [A], starting at [A2]. You want column [B] to show “Priority Region” when the code is “North” or “South,” and “Standard” otherwise.
- Prepare sample data:
- [A2]=North
- [A3]=East
- [A4]=South
- [A5]=West
- In [B2] enter:
=IF( OR(A2="North", A2="South"), "Priority Region", "Standard")
- Copy the formula down to [B5]. Expected results: [B2] and [B4] read “Priority Region,” while [B3] and [B5] read “Standard.”
Why it works: OR evaluates each comparison (A\2=\"North\") and (A\2=\"South\"). The function returns TRUE if either is TRUE. IF then outputs “Priority Region.” This mirrors the natural language rule exactly.
Common variations:
- Add “Central” as another priority by including it inside OR.
- Replace the hard-typed return strings with cell references—useful for multilingual dashboards.
- Use conditional formatting tied to the same logical test to apply colored highlights in addition to text.
Troubleshooting tips:
- If all rows show “Standard” confirm spelling—“north” ≠ “North.”
- Watch out for leading/trailing spaces when copying data from other systems; wrap A2 with TRIM inside the OR tests if needed.
- Ensure quotation marks are straight quotes if you pasted from a word processor.
Example 2: Real-World Application – Commission Rate Table
A sales company pays 12 percent commission when the “Channel” field is “Email” or “Social,” and only 7 percent for all other channels. Total sale amounts sit in column [C]. We need a formula to calculate commission dollars in [D].
Sample setup:
| Row | Channel | Amount |
| 2 | Social | 15,000 |
| 3 | Affiliate | 8,000 |
| 4 | Email | 12,500 |
| 5 | Direct | 20,000 |
Step-by-step:
- Store commission rates in named cells for flexibility:
- In [G1] type 0.12 and name it HighRate.
- In [G2] type 0.07 and name it LowRate.
- In [D2] enter:
=IF( OR(B2="Email", B2="Social"), C2*HighRate, C2*LowRate )
- Copy to [D5]. Results:
- [D2]=1800
- [D3]=560
- [D4]=1500
- [D5]=1400
Business context: By embedding the logic inside each row, managers instantly see dollar commissions adjust when they reclassify a channel. This empowers scenario planning—changing HighRate in [G1] updates every formula.
Integration tips:
- Summarize total commissions with SUM on [D:D] or a dynamic SUMIFS per representative.
- Create a slicer-controlled PivotTable and keep formulas intact for ad-hoc what-ifs.
- Protect the HighRate and LowRate cells to avoid accidental edits.
Performance considerations: On sheets with 100,000+ rows, IF + OR remains efficient because each row calculates in memory in a single pass. However, ensure the entire dataset uses Excel Tables so formulas auto-expand without manual copy operations.
Example 3: Advanced Technique – Dynamic “This or That” List with XLOOKUP
You might need to test against a list that changes weekly—for instance, a compliance team maintains a list of “High-Risk Countries” in [K2:K20]. Instead of hard-coding every country, use XLOOKUP’s match ability inside IF.
Scenario: Flag shipments in column [A] if the destination country is on the high-risk list or if the shipment value in [B] is above 1 million.
- Name the list [K2:K20] as HighRiskCountries.
- In [C2] (the “Status” column) enter:
=IF( OR( NOT(ISNA( XLOOKUP(A2, HighRiskCountries, HighRiskCountries) )), B2>1000000 ), "Review", "Normal")
Explanation:
- XLOOKUP searches for [A2] in HighRiskCountries; if found, it returns the match, otherwise #N/A.
- ISNA checks for #N/A; wrapping with NOT converts \"found\" to TRUE.
- OR then checks either “country found” or “value greater than 1 million.”
- IF outputs “Review” when any condition is met.
Advanced points:
- XLOOKUP offers exact match by default and is dynamic—add a new country to the list, and the formula reacts at once.
- The value threshold uses a standard comparison; you can also reference a cell threshold for user control.
- Performance is excellent: XLOOKUP uses binary search on sorted lists or hash-based search on unsorted ones. For thousands of rows the overhead is minimal.
Error handling:
- Wrap the entire formula in IFERROR when upstream data can contain TEXT mixed with NUMBERS, or pre-validate numeric shipment values with ISNUMBER.
Professional tip: Pair this logic with conditional formatting to shade “Review” rows in light red, helping auditors focus on exceptions immediately.
Tips and Best Practices
- Store comparison strings in named ranges so non-technical users update rules without touching formulas.
- Use Excel Tables; structured references like [@Channel] replace row-specific addresses and auto-expand.
- For readability, indent arguments in the formula bar (Alt + Enter inside the formula) when OR lists many items.
- Apply EXACT or UPPER around text comparisons when consistency of case matters in downstream processes.
- Leverage IFERROR to convert #N/A results from lookup-based tests into FALSE, preventing accidental TRUE outcomes.
- For performance, avoid volatile functions such as TODAY inside the logical tests unless absolutely necessary.
Common Mistakes to Avoid
- Hard-coding text with inconsistent spacing or case – “North ” (extra space) never equals “North.” Solution: use TRIM and proper data validation.
- Nesting IF statements instead of using OR – rapidly becomes unreadable. If you find yourself at three nested IFs, stop and refactor to OR or IFS.
- Forgetting to lock references (F4) when copying formulas – a comparison cell can shift unintentionally. Anchor ranges with absolute references like $K$2:$K$20.
- Mixing numeric and text data types – “1000” stored as text never triggers a numeric comparison. Coerce with VALUE or precede the cell with two minus signs (--).
- Omitting error handling when using lookups – a missing value returns #N/A, causing OR to propagate an error rather than return FALSE. Always wrap lookup pieces in ISNA or IFERROR.
Alternative Methods
Below is a comparison of popular approaches:
| Method | Excel Version Support | Pros | Cons | Best For |
|---|---|---|---|---|
| IF + OR | 2007+ | Universal, simple, clear | Hard-coded list in formula | 2–5 comparisons |
| IFS (multiple conditions) | 2019 / 365 | No nesting, cleaner syntax | No OR logic built-in; still needs OR for “this or that” | Sequential cascading rules |
| SWITCH | 2019 / 365 | Elegant for exact text matches | Limited to equality comparisons, no ranges | Many exact matches with single return field |
| XLOOKUP / VLOOKUP with table | 365 / 2019+ (XLOOKUP) or 2007+ (VLOOKUP) | Scalable, central list maintenance | Requires lookup setup, may need IFERROR | Dynamic lists, maintenance by non-developers |
| Power Query conditional column | Excel 2016+ | Handles millions of rows, database-like | Refresh needed, not real-time | Data transformation pipelines |
When to switch methods: If your “this or that” list regularly exceeds 10 items, migrate from OR to a lookup table. If you’re shaping data before analysis, Power Query is often better because it separates transformation from analysis.
FAQ
When should I use this approach?
Use IF + OR when you need to evaluate a small, fixed set of alternative values or conditions directly in the grid, and users expect results to update instantly as they type.
Can this work across multiple sheets?
Yes. Reference cells or ranges on other sheets by prefixing the sheet name: =IF( OR(Sheet2!A2="North", Sheet3!B5="Priority"), "Yes", "No"). For lists, use named ranges so sheet location is abstracted.
What are the limitations?
IF + OR becomes unwieldy beyond roughly eight comparisons, and it cannot return arrays natively. It also evaluates every test regardless of earlier TRUE results, which may slow very complex workbooks.
How do I handle errors?
Wrap lookup-based comparisons in ISNA or IFERROR. For numeric divisions, test denominators before division. Example: =IFERROR( your_formula, "Check data").
Does this work in older Excel versions?
Yes. IF + OR operates in Excel 2003 as long as the file format supports the formula. Newer functions like IFS, SWITCH, and XLOOKUP require Excel 2019 or Microsoft 365.
What about performance with large datasets?
For 100,000+ rows, keep formulas non-volatile, convert data ranges to Excel Tables, and use lookup tables rather than long OR lists. Calculate on demand rather than letting formulas recalculate constantly.
Conclusion
Mastering “If cell is this or that” equips you with a core decision-making tool that powers virtually every analytical spreadsheet. Whether you’re flagging critical orders, assigning commission rates, or routing workflow tasks, the combination of IF with OR (or its modern cousins) lets you translate business rules directly into live, auditable formulas. Invest time in clean data preparation, named ranges, and appropriate method selection, and your models will remain fast, flexible, and easy to maintain. Keep practicing by building progressively more complex scenarios, and soon conditional logic will become second nature across your Excel projects.
Related Articles
How to Show the 10 Most Common Text Values in Excel
Learn multiple Excel methods to list the 10 most frequent text values—complete with step-by-step examples, business use cases, and expert tips.
How to Abbreviate Names Or Words in Excel
Learn multiple Excel methods to abbreviate names or words with step-by-step examples and practical applications.
How to Abbreviate State Names in Excel
Learn multiple Excel methods to abbreviate state names with step-by-step examples, professional tips, and real-world applications.