Multiple If Statements (Between)

reneev

Board Regular
Joined
Apr 26, 2017
Messages
53
I'm trying to make a formula that basically says if this number (4.57) is between B and C, then pull in A. Since there is more than 7 options, a regular IFTHAN statement won't work. I just can't think anymore and need help.

[TABLE="width: 178"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]0 - 6 mo[/TD]
[TD]0[/TD]
[TD]0.5[/TD]
[/TR]
[TR]
[TD]6+ mo - 1 yr.[/TD]
[TD]0.6[/TD]
[TD]0.99[/TD]
[/TR]
[TR]
[TD]1 - 2 years[/TD]
[TD]1[/TD]
[TD]1.99[/TD]
[/TR]
[TR]
[TD]2 - 3 years[/TD]
[TD]2[/TD]
[TD]2.99[/TD]
[/TR]
[TR]
[TD]3 - 4 years[/TD]
[TD]3[/TD]
[TD]3.99[/TD]
[/TR]
[TR]
[TD]4 - 5 years[/TD]
[TD]4[/TD]
[TD]4.99[/TD]
[/TR]
[TR]
[TD]5 - 10 years [/TD]
[TD]5[/TD]
[TD]9.99[/TD]
[/TR]
[TR]
[TD]10 - 15 years [/TD]
[TD]10[/TD]
[TD]14.99[/TD]
[/TR]
[TR]
[TD]15 - 20 years[/TD]
[TD]15[/TD]
[TD]19.99[/TD]
[/TR]
[TR]
[TD]20+ years[/TD]
[TD]20[/TD]
[TD]100[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Can you store that table somewhere in your workbook so you can reference it? If so, you can do a simple Index/Match

Code:
=INDEX(A1:C10,MATCH(E1,B1:B10,1),1)

Where A1:C10 is the table, E1 is the value I was looking up.

ETA, you may want to name the ranges that you are looking up to make it easier to read:

Code:
=INDEX(LookupTable,MATCH(E1,LookupAge,1),1)
 
Last edited:
Upvote 0
Thank you for your response. In my original post, I didn't realize that I wasn't explaining it right. The number is actually a column of varying numbers where each needs to be compared against the table and determined the year category. So if A1 is between B1 and C2 Or B2 and C2 (and so on) then return whatever is in column D.
 
Upvote 0
I think you are going to have to give a better example of what your actual data looks like, and what the expected result is.
 
Upvote 0
Oh how's this:

I want the formula to look at the YOS and determine which service category it belongs in. The YOS field varies depending on the employee.

[TABLE="class: grid, width: 175"]
<tbody>[TR]
[TD="align: center"]Years of Service (YOS)[/TD]
[TD="align: center"]Service Category[/TD]
[/TR]
[TR]
[TD="align: center"].6[/TD]
[TD="align: center"]??[/TD]
[/TR]
[TR]
[TD="align: center"]5.2[/TD]
[TD="align: center"]??[/TD]
[/TR]
[TR]
[TD="align: center"]21.5[/TD]
[TD="align: center"]??[/TD]
[/TR]
</tbody>[/TABLE]
*The YOS cell is a formula based on hire date minus term date so it's not a round number.


Service Category options:

[TABLE="class: grid, width: 250"]
<tbody>[TR]
[TD="align: center"]From[/TD]
[TD="align: center"]To[/TD]
[TD="align: center"]Service Category[/TD]
[/TR]
[TR]
[TD]0[/TD]
[TD].49[/TD]
[TD]0-6 months[/TD]
[/TR]
[TR]
[TD].5[/TD]
[TD].99[/TD]
[TD]6 mos - 1 year[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1.99[/TD]
[TD]1 - 2 years[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2.99[/TD]
[TD]2 - 3 years[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3.99[/TD]
[TD]3 - 4 years[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4.99[/TD]
[TD]4 - 5 years[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]9.99[/TD]
[TD]5 - 10 years[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]14.99[/TD]
[TD]10 - 15 years[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]19.99[/TD]
[TD]15 - 20 years[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]50[/TD]
[TD]20+ years[/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:
Upvote 0
All you need for that is VLOOKUP.

Like this, change ranges as necessary.


Excel 2010
ABCDEFGH
1Years of Service (YOS)Service CategoryFromToService Category
20.66 mos - 1 year00.490-6 months
35.25 - 10 years0.50.996 mos - 1 year
421.520+ years11.991 - 2 years
522.992 - 3 years
633.993 - 4 years
744.994 - 5 years
859.995 - 10 years
91014.9910 - 15 years
101519.9915 - 20 years
11205020+ years
Sheet1
Cell Formulas
RangeFormula
B2=IF(A2="","",VLOOKUP(A2,$F$2:$H$11,3,1))
B3=IF(A3="","",VLOOKUP(A3,$F$2:$H$11,3,1))
B4=IF(A4="","",VLOOKUP(A4,$F$2:$H$11,3,1))
 
Last edited:
Upvote 0
How about


Excel 2013/2016
ABCDEF
1FromToService CategoryYears of Service (YOS)Service Category
200.490-6 months0.66 mos - 1 year
30.50.996 mos - 1 year5.25 - 10 years
411.991 - 2 years21.520+ years
522.992 - 3 years
633.993 - 4 years
744.994 - 5 years
859.995 - 10 years
91014.9910 - 15 years
101519.9915 - 20 years
11205020+ years
Index
Cell Formulas
RangeFormula
F2=INDEX($A$2:$C$11,MATCH(E2,$A$2:$A$11,1),3)
 
Upvote 0
like this?

Code:
=INDEX(C1:C10,MATCH(YOS!A1,A1:A10,1))

c1:c10 - service category
a1:a10 - from (in service category)
 
Upvote 0
YES!! That worked! Can you explain what the "","" means in this part of the formula IF(A2="",""
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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