IF statement: how to leave cell blank if condition is false ("" does not work)

ExcelIf StatementExcel 2010Worksheet Function

Excel Problem Overview


I would like to write an IF statement, where the cell is left blank if the condition is FALSE. Note that, if the following formula is entered in C1 (for which the condition is false) for example:

 =IF(A1=1,B1,"")

and if C1 is tested for being blank or not using =ISBLANK(C1), this would return FALSE, even if C1 seems to be blank. This means that the =IF(A1=1,B1,"") formula does not technically leave the cells blank if the condition is not met.

Any thoughts as to a way of achieving that? Thanks,

Excel Solutions


Solution 1 - Excel

Unfortunately, there is no formula way to result in a truly blank cell, "" is the best formulas can offer.

I dislike ISBLANK because it will not see cells that only have "" as blanks. Instead I prefer COUNTBLANK, which will count "" as blank, so basically =COUNTBLANK(C1)>0 means that C1 is blank or has "".

If you need to remove blank cells in a column, I would recommend filtering on the column for blanks, then selecting the resulting cells and pressing Del. After which you can remove the filter.

Solution 2 - Excel

Try this instead

=IF(ISBLANK(C1),TRUE,(TRIM(C1)=""))

This will return true for cells that are either truly blank, or contain nothing but white space.

See this post for a few other options.

edit

To reflect the comments and what you ended up doing: Instead of evaluating to "" enter another value such as 'deleteme' and then search for 'deleteme' instead of blanks.

=IF(ISBLANK(C1),TRUE,(TRIM(C1)="deleteme"))

Solution 3 - Excel

I wanted to add that there is another possibility - to use the function na().

e.g. =if(a2 = 5,"good",na());

This will fill the cell with #N/A and if you chart the column, the data won't be graphed. I know it isn't "blank" as such, but it's another possibility if you have blank strings in your data and "" is a valid option.

Also, count(a:a) will not count cells which have been set to n/a by doing this.

Solution 4 - Excel

If you want to use a phenomenical (with a formula in it) blank cell to make an arithmetic/mathematical operation, all you have to do is use this formula:

=N(C1)

assuming C1 is a "blank" cell

Solution 5 - Excel

You could try this.

=IF(A1=1,B1,TRIM(" "))

If you put this formula in cell C1, then you could test if this cell is blank in another cells

=ISBLANK(C1)

You should see TRUE. I've tried on Microsoft Excel 2013. Hope this helps.

Solution 6 - Excel

I've found this workaround seems to do the trick:

Modify your original formula:

=IF(A1=1,B1,"filler")

Then select the column, search and replace "filler" with nothing. The cells you want to be blank/empty are actually empty and if you test with "ISBLANK" it will return TRUE. Not the most elegant, but it's quick and it works.

Solution 7 - Excel

The easiest solution is to use conditional formatting if the IF Statement comes back false to change the font of the results cell to whatever color background is. Yes, technically the cell isn't blank, but you won't be able to see it's contents.

Solution 8 - Excel

This shall work (modification on above, workaround, not formula)

Modify your original formula: =IF(A1=1,B1,"filler")

Put filter on spreadsheet, choose only "filler" in column B, highlight all the cells with "filler" in them, hit delete, remove filter

Solution 9 - Excel

You can do something like this to show blank space:

=IF(AND((E2-D2)>0)=TRUE,E2-D2," ")

Inside if before first comma is condition then result and return value if true and last in value as blank if condition is false

Solution 10 - Excel

The formula in C1

=IF(A1=1,B1,"")

is either giving an answer of "" (which isn't treated as blank) or the contents of B1.

If you want the formula in D1 to show TRUE if C1 is "" and FALSE if C1 has something else in then use the formula

=IF(C2="",TRUE,FALSE)

instead of ISBLANK

Solution 11 - Excel

Here is what I do

=IF(OR(ISBLANK(AH38),AH38=""),"",IF(AI38=0,0,AH38/AI38))

Use the OR condition OR(ISBLANK(cell), cell="")

Solution 12 - Excel

I think all you need to do is to set the value of NOT TRUE condition to make it show any error then you filter the errors with IFNA().

Here is what your formula should look like =ifna(IF(A1=1,B1,NA()))

Here is a sheet that returns blanks from if condition : https://docs.google.com/spreadsheets/d/15kWd7oPWQmGgYD_PLz9YpIldwnKWoXPHtHQAT3ulqVc/edit?usp=sharing

Nope ... that only works for Googlesheets ... not Excel.

Solution 13 - Excel

To Validate data in column A for Blanks

Step 1: Step 1: B1=isblank(A1)

Step 2: Drag the formula for the entire column say B1:B100; This returns Ture or False from B1 to B100 depending on the data in column A

Step 3: CTRL+A (Selct all), CTRL+C (Copy All) , CRTL+V (Paste all as values)

Step4: Ctrl+F ; Find and replace function Find "False", Replace "leave this blank field" ; Find and Replace ALL

There you go Dude!

Solution 14 - Excel

Instead of using "", use 0. Then use conditional formating to color 0 to the backgrounds color, so that it appears blank.

Since blank cells and 0 will have the same behavior in most situations, this may solve the issue.

Solution 15 - Excel

This should should work: =IF(A1=1, B1)

The 3rd argument stating the value of the cell if the condition is not met is optional.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMayouView Question on Stackoverflow
Solution 1 - ExceltigeravatarView Answer on Stackoverflow
Solution 2 - ExcelAutomate ThisView Answer on Stackoverflow
Solution 3 - Exceluser3791372View Answer on Stackoverflow
Solution 4 - ExcelNickView Answer on Stackoverflow
Solution 5 - ExcelYugo GautomoView Answer on Stackoverflow
Solution 6 - Exceluser3285247View Answer on Stackoverflow
Solution 7 - Excelb creativeView Answer on Stackoverflow
Solution 8 - Excelguest XLView Answer on Stackoverflow
Solution 9 - ExcelDeepanshu VatsView Answer on Stackoverflow
Solution 10 - ExcelChrisMView Answer on Stackoverflow
Solution 11 - ExcelTalhaView Answer on Stackoverflow
Solution 12 - ExcelMahmoud SamahaView Answer on Stackoverflow
Solution 13 - ExcelRaj BunnuView Answer on Stackoverflow
Solution 14 - ExcelNeinView Answer on Stackoverflow
Solution 15 - ExcelHeather StarkView Answer on Stackoverflow