IF Function when logical test between two values

wealthanalyst

New Member
Joined
Aug 7, 2009
Messages
8
I need to create the following IF function, and I am not sure how to do it.

IF(X is between Y and Z, then A)

Thanks
 
Hi and welcome to the board!!!
Have you looked at the AND function??
Code:
=IF(X>Y,X<Z,A,"")[ p code]<> < Z,A,"")
lenze
 
Upvote 0
Try a formula like

=IF(AND(C1>=A1,C1<=B1),"between","not between")

I have tried this and not sure what I am doing wrong. My formula is:
=IF(AND(A2>=B2,A2<=B2),C2,"1")
My goal is to have "if between these 2 times, then cell C2=1 if true, or 0 if false.
 
Upvote 0
I have tried this and not sure what I am doing wrong. My formula is:
=IF(AND(A2>=B2,A2<=B2),C2,"1")
My goal is to have "if between these 2 times, then cell C2=1 if true, or 0 if false.

try this
Code:
=IF(AND(A2>=B2,A2<=B2),C2="1",0)

Note: Assuming you are writing the formula in cell C2
 
Upvote 0
I have tried this and not sure what I am doing wrong. My formula is:
=IF(AND(A2>=B2,A2<=B2),C2,"1")
My goal is to have "if between these 2 times, then cell C2=1 if true, or 0 if false.

Part of it the you're checking your times against the same cell - In essence you're nullifying the greater than or less than ranges and will only hit on = B2. It's the same as saying IF(A2=B2, ....

Additionally, if you're using this in cell C2, you're true value is circular - cell C2 should equal cell C2.

In the event that you're logic test returns false, you are also set to make the cell equal "1" instead of 0.

IF syntax - (logical test, value if true, value if false)

For the following example, I'm going to assume your start time is in cell A2, end time is in cell B2, and comparison time is in cell D2 (this formula in C2). The formula would be:

=IF(AND(D2>=A2,D2<=B2),1,0)

Using quotes will provide the numbers as text. You will not be able to perform math functions on them. If you exclude the quotes, your numbers will return as numbers and you will be able to perform math functions.

Best of Luck!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top