very long if statement

gjadcock

New Member
Joined
Sep 17, 2002
Messages
27
Is there any other way to enter this formula

=IF(D6="common","invalid",IF(D6="vert","invalid",IF
(D6="core","invalid",IF(D6="mtg","invalid",IF
(D6="vacant","invalid","bus_unit")))))

I have around 30 room types (common, vert, etc) some are invalid and some are valid, the list will keep growing and I am running out of levels to nest the IF statement.

Thanks
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Thanks, but I need to test the value in the cell if its common, vert etc then I need to set Invalid, else set to Valid
 
Upvote 0
Your if statement show "bus_unit" for blank D6 but your text implies various choices.

You should check help on VLookup or Lookup.

You can also consider

=IF(OR(D6={"common","vert","core","mtg","vacant"}),"invalid","bus_unit")

=LOOKUP(D6&"",{"","Common","Core","Mtg","Vacant";"Bus_unit","Invalid","Invalid","Invalid","Invalid"})

With a lookup table that I named rRooms

=VLOOKUP(D6,rRooms,2,0)

If you want the comment "bus_unit"if D6 is blank

=IF(D6="","bus_unit",VLOOKUP(D6,rRooms,2,0))
This message was edited by Dave Patton on 2002-09-18 09:11
 
Upvote 0
Instead of embedding your list of valid entries in the formula, put them in a column in the worksheet, i.e. if D6 doesn't match an entry from the list in A1 to A10 then "invalid", else "valid".

Enter this in B1 or whereever:
=IF(ISNA(MATCH(D6,A1:A10,0)),"invalid","valid")
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

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