If statement - multiple values and ranges

ryanduck

New Member
Joined
Apr 13, 2011
Messages
37
if I wanted to say:

If A1 is 01-02, 16-23, 36-37

or

If A1 is 03-05, 24-31, 38-40, 56-57

how would I write that?

I've been trying =if((or(range 1, range 2, range 3),"Yes","no"))

with no luck... represented 16-23 as "16<A1<23"
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Try: =IF(OR(AND(A1>=1,A1<=5),AND(A1>=16,A1<=31),AND(A1>=36,A1<=40),AND(A1>=56,A1<=57)),"yes","no")
 
Upvote 0
You will get much better results if you post

What you want to do IF A1 is within each range..

01-02 then Return x
03-05 then return y
etc..

I would imagine a lookup would work well for this.
 
Upvote 0
Maybe

=IF(MATCH(A1,{1,16,36})+MATCH(A1,{37,23,2},-1)=4,"yes","No")
 
Last edited:
Upvote 0
You will get much better results if you post

What you want to do IF A1 is within each range..

01-02 then Return x
03-05 then return y
etc..

I would imagine a lookup would work well for this.


Ok.

if A1 is within any of these ranges (01-02, 16-23, 36-37) I want to return "X"
if A1 is within any of these ranges (03-05, 24-31, 38-40, 56-57) I want to return "Y"
if A1 is within any of these ranges (06-09, 32-34, 41-48, 58-60, 76-77) I want to return "Z"
if A1 is within any of these ranges (10-12, 35, 49-54, 61-66, 78-81) I want to return "A"
if A1 is within any of these ranges (13-15, 55, 67-75, 82-95) I want to return "B"
 
Upvote 0
Something like this perhaps..


Excel Workbook
ABCDEF
137X1X
23Y
36Z
410A
513B
616X
724Y
832Z
935A
1036X
1138Y
1241Z
1349A
1455B
1556Y
1658Z
1761A
1867B
1976Z
2078A
2182B
Sheet1
 
Upvote 0
Maybe extend the table jonmo suggested to F22

<TABLE style="BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 2pt; PADDING-RIGHT: 2pt; FONT-FAMILY: Calibri,Arial; FONT-SIZE: 11pt" border=1 cellSpacing=0 cellPadding=0><COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 46px"><COL style="WIDTH: 46px"></COLGROUP><TBODY><TR style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt; FONT-WEIGHT: bold"><TD> </TD><TD>E</TD><TD>F</TD></TR><TR style="HEIGHT: 18px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">22</TD><TD style="TEXT-ALIGN: right">96</TD><TD>#N/A</TD></TR></TBODY></TABLE>
<TABLE style="BORDER-BOTTOM-STYLE: groove; BORDER-BOTTOM-COLOR: #00ff00; BORDER-RIGHT-STYLE: groove; BACKGROUND-COLOR: #fffcf9; BORDER-TOP-COLOR: #00ff00; FONT-FAMILY: Arial; BORDER-TOP-STYLE: groove; COLOR: #000000; BORDER-RIGHT-COLOR: #00ff00; FONT-SIZE: 10pt; BORDER-LEFT-STYLE: groove; BORDER-LEFT-COLOR: #00ff00"><TBODY><TR><TD>Spreadsheet Formulas</TD></TR><TR><TD><TABLE style="FONT-FAMILY: Arial; FONT-SIZE: 9pt" border=1 cellSpacing=0 cellPadding=2><TBODY><TR style="BACKGROUND-COLOR: #cacaca; FONT-SIZE: 10pt"><TD>Cell</TD><TD>Formula</TD></TR><TR><TD>F22</TD><TD>=NA()</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
to stop values greater than 95 returning a "B" result.
 
Upvote 0

Forum statistics

Threads
1,224,578
Messages
6,179,652
Members
452,934
Latest member
mm1t1

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