# If statement with multiple cells

#### canam

##### Board Regular
Hello

I am trying to write an if statement that uses several posibilities in one statement. Example: =If(E56=(G1:G5),(a1*12),If(E56=(G6:G10,(b1=B8*4)))). This doesn't work even if I list the range as (G1,G2,G3,G4,G5). It tells me there are too many arguments. In my actual sheet my range of values is much larger than G1:G5. Is there any way to get this done? :x Thanks

### 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.
You may solve your problem with Match of Vlookup statements,

ie. If(Vlookup(E56,G1:G5,False),value if true, value if false).

Try posting an example if this doesn't do it for you.

canam said:
Hello

I am trying to write an if statement that uses several posibilities in one statement. Example: =If(E56=(G1:G5),(a1*12),If(E56=(G6:G10,(b1=B8*4)))). This doesn't work even if I list the range as (G1,G2,G3,G4,G5). It tells me there are too many arguments. In my actual sheet my range of values is much larger than G1:G5. Is there any way to get this done? :x Thanks

Your intent is a bit unclear, but guessing at

=IF(ISNUMBER(MATCH(E56,G1:G5,0)),A1*12,IF(ISNUMBER(MATCH(E56,G6:G10,0)),B8*4,"Not in either range."))

We cannot compare a single cell with multiple cells directly. Need to use functions.

This is one way. You will need to turn your logic round because this depends on the value not being found in the range :-

=IF(ISERROR(VLOOKUP(E56,G1:G5,1,FALSE)),1,0)

just jon I used your suggestion and it works perfeclty. Thank you all for the help.

Replies
4
Views
125
Replies
28
Views
637
Replies
19
Views
556
Replies
2
Views
628
Replies
5
Views
134

1,206,833
Messages
6,075,128
Members
446,123
Latest member
junkyardforme

### 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.

### Which adblocker are you using?

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

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