Troubleshooting: IF then Commands working on one sheet but not another

polyocho

New Member
Joined
Dec 28, 2014
Messages
14
I am using a command that works on one sheet in excel but seems to ignore text in another sheet:

=IF(A1="yes",B1& " is my favorite food.","I don’t have a favorite food.") is being used to generate a statement and works in sheet2.

ABC
1YesPorkPork is my favorite food
2NoI don't have a favorite food

<tbody>
</tbody>

But when I use the same code on sheet 1 of my spread sheet it doesnt work after line 1 even if it says the same value in columns A="Yes" B="Pork"? As far as I can tell the formatting of cells is all the same "general" format but for every line: whether I say Yes or no it just says "I don't have a favorite food"

ABC
1YesPorkPork is my favorite food
2YesPorkI don't have a favorite food

<tbody>
</tbody>

Any ideas how I might adapt the formula to correct this error?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
have you managed to add a space to the bottom one
 
Upvote 0
If I use the following code
=IF(B1="Yes",C1&" is my favorite food",IF(B1="No","I don't have a favorite food.",IF(B1="",""))) then for the cells with Yes in column B column C displays "False"
 
Upvote 0
I dont think I am adding a space because I am just dragging the code down to autocopy it on subsequent lines. I do think that the error appears to be with the A & B area rather than the code because if I copy and paste the A, B, C from line 1 where it works and then change the answers back to what they said before then it works. So maybe some way to clean the code from columns A & B before applying the formula will work??
 
Upvote 0
I dont think I am adding a space because I am just dragging the code down to autocopy it on subsequent lines. I do think that the error appears to be with the A & B area rather than the code because if I copy and paste the A, B, C from line 1 where it works and then change the answers back to what they said before then it works. So maybe some way to clean the code from columns A & B before applying the formula will work??
 
Upvote 0
glad it worked, does it still work with just =trim(a1)
 
Upvote 0
substitute as given there, changes a character for another, one that can be worked with easily. trim on its own means your cell had a leading or trailing space, and for the formula to work you need an exact match
 
Upvote 0

Forum statistics

Threads
1,214,981
Messages
6,122,565
Members
449,089
Latest member
Motoracer88

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