# IF, AND but no idea!

#### Scruffy77

##### New Member
Hello,
I'm new to AND statements and was wondering if someone could help me.
I'm trying to make a formula (I believe an IF/AND statement will do) that will look at 2 columns and if both values are equal to what I specify, then it returns a value I specify into another column. If either of the values are not equal to the value I specify, it returns a blank

i.e
if Column A is equal to "X", and column B is equal to "Y", then return "004" in Column C,
and if either Column A OR B is not equal to the values I set out (A= X and B = Y) then return blank

(Note: If Column A is = to X, but Column B is not equal to "Y", it returns blank or vice versa)

Perhaps I'm making this more complicated, but I'm trying to work it out and it's not working!

If anyone has any ideas please let me know.

### Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use \$ signs: \$V\$2:\$Z\$99 will always point to V2:Z99, even after copying
=If(And(A1="X",B1="Y"),"004","")

=IF(AND(A1="X", B1="Y"), "004", "")

Edit: Sorry didn't see the previous post

Thank you

Thank you! It works perfectly!
I reason I was having trouble with it was that the second value was a number and I was putting quotes around it..

Thanks again!

Replies
2
Views
131
Replies
4
Views
761
Replies
7
Views
215
Replies
9
Views
566
Replies
7
Views
178

1,203,758
Messages
6,057,180
Members
444,913
Latest member
ILGSE

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