avoid embedded if statements

  • Thread starter Thread starter ellebelle
  • Start date Start date
E

ellebelle

Hello,

Is there a quick way to do multiple if statements rather than using an
embedded if statement?

I have the following:

If A1 = 1 then write carpet, If A1 = 2 then write couch, If A1 = 3 then
write table and so on.

Is there an easier way?

Ellen
 
The easier way is to use a lookup, the most common being the Vlookup
function.

Regards,
Fred
 
Hello,

Is there a quick way to do multiple if statements rather than using an
embedded if statement?

I have the following:

If A1 = 1 then write carpet, If A1 = 2 then write couch, If A1 = 3 then
write table and so on.

Is there an easier way?

Ellen

=choose(a1,"carpet","couch","table")

or

=INDEX(E1:E3,A1)

Where
E1: carpet
E2: couch
E3: table

If your A1 values are not sequential, you could use VLOOKUP


--ron
 
If you have several items, then you could do it this way:

=CHOOSE(A1,"carpet","couch","table","and so on")

The drawback is that you have to amend the formula if you want to add/
delete/amend items.

Alternatively, you could set up a table somewhere like this (eg in
X1:Y3):

1 carpet
2 couch
3 table

and then use:

=VLOOKUP(A1,X1:Y10,2,0)

Here you can add items to the table without amending the formula
(although the range will have to cover the the extent of the table).

Hope this helps.

Pete
 
Back
Top