More =IF formula issues

LlebKcir

Board Regular
Joined
Oct 8, 2018
Messages
219
A simple =IF statement checks a value in a cell on a different worksheet for TRUE/FALSE and performs the string paste accordingly. I have removed the "" from around the boolean TRUE/FALSE.

The boolean values are copy/paste value from another workbook. Some formulas will update, many will not until I manually retype the TRUE/FALSE values into the cells, and even after that there are still formulas that refuse to update.

Code:
=IF('Table'!G$20=TRUE,$B$4&"_AI"&M26&"-"&C26&" "&F26,$B$4&"_AI"&M26&"-"&C26&" "&F26&"-SPARE")

I have manually types TRUE into Table G20 multiple times, the above formula is still evaluating FALSE and placing the -SPARE at the end of the string.

=IF('Table'!G20=TRUE,"YES","NO")

I just ran that in a blank unused cell, it is evaluating to NO. That is the incorrect output. Table G20 clearly has TRUE typed in that cell and it is formatted General.

side note: After typing true and not TRUE in the cell allowing for Excel to convert to boolean and force to uppercase, the formula functions as expected and removes the -SPARE from the string and the short test code evaluates to YES.

What is wrong with Excel and my formula?
 
Last edited by a moderator:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi there. I think what is happening is that you are confusing boolean and text values at different points. If the copied values are TRUE or FALSE, these are text fields, not boolean. Typing TRUE into G20 merely sets the contents of that cell to the letters T,R,U,E - it doesn't make it a boolean. Try making all your comparisons text and see if that helps. I would wrap UPPER() around every value you are comparing as well.
 
Upvote 0
Hi there. I think what is happening is that you are confusing boolean and text values at different points. If the copied values are TRUE or FALSE, these are text fields, not boolean. Typing TRUE into G20 merely sets the contents of that cell to the letters T,R,U,E - it doesn't make it a boolean. Try making all your comparisons text and see if that helps. I would wrap UPPER() around every value you are comparing as well.

That is very possible, but following this thread:

https://www.mrexcel.com/forum/excel-questions/1108822-if-formula-output-not-expected.html

is the reason I think it might be better to stick with boolean over text.
 
Upvote 0
It's possible the cell format was text when the TRUE was entered initially. Subsequently just changing the format to General would not convert the content to a Boolean, but retyping the value again would.
 
Upvote 0
Typing TRUE into G20 merely sets the contents of that cell to the letters T,R,U,E
@jmacleary - are you sure ?

If true is typed into G20, the value returned is centre-aligned and changes to TRUE
Text would be left-aligned and left unchanged as true

(unless cell number format = text)
 
Last edited:
Upvote 0
RoryA, that could possibly happen. The spreadsheet I am copying the data from used vb code .value=.value, does that change the output format?

Lets call that workbook, workbook A.

In workbook A, I use array formula to pull data from another workbook (Master). Then vb code runs .value=.value to remove the array formula and keep the raw data. I copy/paste the raw data from workbook A into workbook B. My issue is in workbook B not treating TRUE/FALSE as expected.

Boolean would be ideal, IMHO.
 
Upvote 0
Test the type of value in G20 with

=CELL("type",G20)

If it returns V it is boolean, if it returns L it is text
 
Upvote 0
Yongle You are right if the original cells were boolean values, I (maybe wrongly) thought they may be text, which, reading LiebKcir's latest post may well be the case.
 
Last edited:
Upvote 0
If you are getting inconsisitent values in cells (sometimes boolean, sometime text), then how about using this method ...

=IF(OR('Table'!G20=TRUE,'Table'!G20="TRUE"),"YES","NO")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,142
Members
448,551
Latest member
Sienna de Souza

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