# Thread: If statement

1. ## If statement

Im trying to write an if statement that says if cell A1 says "17,30,87,38" then change cell B1 to say "Home" if not say "". It never says "Home" only ""
=If(A1="17,30,87,38","Home","")

2. Herman,

Welcome to the Lounge as a new poster.

I think you are saying that if A1 = 17 or 30 or 87 or 38 then the value in B1 should be Home otherwise it is blank?

Cell B1 Formula: =If(A1=17,"Home",If(A1=30,"Home",If(A1=38,"Home",I f(A1=87,"Home",""))))

Another Option: =If(OR(A1=17,A1=30,A1=38,A1=87),"Home","")

HTH

3. And another option:
=If(OR(A1={17,30,38,87}),"Home","")

4. ## The Following User Says Thank You to rory For This Useful Post:

RetiredGeek (2014-10-27)

5. Rory,

Cool! I didn't know you could do that!

6. Cool? It's very cool!

I'm always writing OR statements where I repeat the cell within the parens. Using the {set} braces (or array braces) is very cool.

Fred

7. All the number are in one cell with command in between them.

8. If the (text) string: 17,30,87,38 is in cell A1, and you place your formula in B1: =If(A1="17,30,87,38","Home","")

That should work. Be sure you don't have an extra space after the 38, or any other extra characters.
Make sure all of the separators are commas and there are no extra spaces.

9. ## The Following User Says Thank You to kweaver For This Useful Post:

Herman Escobedo (2014-10-27)

10. Herman,

Could you possibly post a sample worksheet?

11. I got it working thank you all. I was missing the "" around home.

12. Hi RG

Further to Roy's post #3, you can also use
{=IF(OR(A1=myList),"Home","")}

entered as an array formula, where you have defined name myList referring to a block of cells containing the required values. (It doesn't matter if the named range is a vertical list of cells or a horizontal range of cells).
This can be useful if the list of valid values is long or you want to change them easily.

zeddy

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•