Between Formula in Excel [Quick Tips]

Share

Facebook
Twitter
LinkedIn

In today’s quick tip, lets find how to check for between conditions in Excel using formulas, like this:

Between Formula - Testing for between condition in Excel

Between Formula in Excel for Numbers:

Lets say you have 3 values in A1, A2 and A3. And you want to find out if A1 falls between A2 and A3.

Now, the simplest formula for such a thing would be test whether the conditions A1>=A2, A1<=A3 are both true. Hence, it would look like,
=if(AND(A1>=A2,A1<=A3),"Yes", "No")

However, there are 2 problems with a formula like above:

1. It assumes that A2 is smaller than A3.
2. It is just too big.

Shouldn’t there be a shorter and simpler formula?!?

Well, there is. Last week when chatting with Daniel Ferry, he mentioned a darned clever use of MEDIAN formula to test this. It goes like,

=if(A1=MEDIAN(A1:A3),"Yes","No")

Now, not only does the above formula look elegant and simple, it also works whether A2 is smaller or larger than A3.

Between Formula in Excel for Dates:

Well, dates are just numbers in Excel. So you can safely use the technique above to test if a given date in A1 falls between the two dates in A2 and A3, like this:
=if(A1=MEDIAN(A1:A3),"Yes","No")

Between Formula for Text Values:

Lets say you want to find-out if the text in A1 is between text in A2 and A3 when arranged alphabetically, a la in dictionary. You can do so in Excel using,

wait for it…

that is right, <= and >= operators, like this:
=if(AND(A1>=A2,A1<=A3),"Yes", "No")

Between Formulas in Excel – Summary and Examples:

Here is a list of examples and the corresponding Excel Formulas to test the between condition.

Between Formula in Excel - Examples

Do you check for Between Conditions in Excel?

Checking if a value falls between 2 other values is fairly common when you are working with data. I would love to know how you test for such conditions in excel? What kind of formulas do you use?

Share using comments.

Recommended Excel Formula Tutorials:

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

One Response to “How to compare two Excel sheets using VLOOKUP? [FREE Template]”

  1. Danny says:

    Maybe I missed it, but this method doesn't include data from James that isn't contained in Sara's data.

    I added a new sheet, and named the ranges for Sara and James.

    Maybe something like:
    B2: =SORT(UNIQUE(VSTACK(SaraCust, JamesCust)))
    C2: =XLOOKUP(B2#,SaraCust,SaraPaid,"Missing")
    D2: =XLOOKUP(B2#,JamesCust, JamesPaid,"Missing")
    E2: =IF(ISERROR(C2#+D2#),"Missing",IF(C2#=D2#,"Yes","No"))

    Then we can still do similar conditional formatting. But this will pull in data missing from Sara's sheet as well.

Leave a Reply