Help with IF Statement

edam4i

New Member
Joined
Jul 28, 2018
Messages
11
How do I get to check two cells if they match and then return a value?

I'm using an Id Statement but it's working for 2 out of 3 scenarios.

=IF(A1=B1,1,0)

A1 B1 C1
HAM HAM 0
BEEF BEEF 1
TURKEY TURKEY 1

The If Statement works on BEEF=BEEF and TURKEY=TURKEY but not HAM=HAM?

Please help!
Colin
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Hi,

If that's not working for HAM=HAM, that means they're not equal, you may have leading and/or trailing spaces in the cells.

Assuming you have HAM in A1, and HAM in B1,
In an unused cell put:

=LEN(A1)

In another unused cell put:

=LEN(B1)

What do you get?
 
Upvote 0
jtakw, sandy's TRIM should have picked that up (unless it was a carriage return)?
But LEN should ID any differences in characters
 
Upvote 0
jtakw, sandy's TRIM should have picked that up (unless it was a carriage return)?
But LEN should ID any differences in characters

Yes Ford, I know Post #2 formula using TRIM will take care of possible leading and/or trailing spaces, but I was trying to help OP get to the "root" problem (possibly stopping the cause of leading/trailing spaces)…
if possible...
 
Upvote 0
I agree, thats why I said your LEN should help in that case :)

Thanks all!
I tried all of your suggestions but nothing worked.

I used HAM, TURKEY and BEEF as a pure example.

However the data I am trying to match is based on a result on the input from other cells so the data in any of the cells such as HAM/TURKEY or BEEF can alway be different but will alway be only one of three outputs (HAM, TURKEY or BEEF).

There are no trailing characters or spaces etc.

If I enter a value in A1 manually then the value in B1 will either be HAM/TURKEY or BEEF based on what I enter in A1.

Then I want to manually enter another value in Cell C1 and if the value I enter in C1 matches the exact same value that displays in B1 I want to return a different value in Cell D1 as the final result.

I hope this explains it better?

All help greatly appreciated.

so
After manually entering a value say "1" in Cell A1 I have it programmed that B1 will Display "Ham"
After manually entering a value say "2" in Cell A1 I have it programmed that B1 will Display "Turkey"
After manually entering a value say "3" in Cell A1 I have it programmed that B1 will Display "Beef"

After either Ham/Turkey or Beef is displayed in B1 depending on what value I enter in A1 (1,2 or 3) I then will manually enter another value in C1.

Example:

A1 - Manually enter "1"
B1 - Displays "Ham"

then

C1 - Manually enter "Pig"
D1 - Displays "Yes"

So if I enter A1"2" it should display B1 "Turkey" and I enter C1 "Bird" D1 should display "No"
So if I enter A1"3" it should display B1 "Beef" and I enter C1 "Cow" D1 should display "Maybe"

So for three possible conditions after I manually enter one of three values in Cell C1 (Pig,Bird or Cow) there should be one of three possible values displayed in Cell D1.

Problem I am having is I am only getting two conditions met the third one isn't displaying anything regardless of the value entered in Cell C1.
 
Upvote 0
So what are the formulas you are using to get "HAM", etc. in B1?
 
Last edited:
Upvote 0
Okay I think I have discovered what the problem actually is.

When I use the following statement =IF(B1=C1,1,0) it only works if I am matching characters against characters not Numbers v Numbers.
Problem is semi-solved.

When I input words instead of numbers and match everything works fine but I need to use a mixture so maybe the IF Statement isn't suitable?
any suggestions?
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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