avoid embedded if statements

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
 
F

Fred Smith

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

Regards,
Fred
 
R

Ron Rosenfeld

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
 
P

Pete_UK

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top