Check whether one of several cells is blank - excel-formula

How to check whether one of several cells is blank?
I know that ISBLANK(cell) or LEN(cell) can be used to check whether a cell is empty, but I don't know how to apply them to "one of several cells"

Try =IF(COUNTA(UNIQUE(ISBLANK(range)))=2, TRUE, FALSE)
Another option is something like
=IF(COUNTA(H2:H4)-ROWS(H2:H4)=0, FALSE, TRUE)
EDIT: If your range is horizontal, you'll want to use something like =IF(COUNTA(UNIQUE(ISBLANK(range),1))=2, TRUE, FALSE) or =IF(COUNTA(UNIQUE(TRANSPOSE(ISBLANK(range))))=2, TRUE, FALSE)

Euler's Disgraced Stepchild's answer works perfectly.
And I also figured out another approach just now so I post it here anyway:
=IF(COUNTBLANK(range)=0, "Complete", "Incomplete")

Related

How do I get rid of "FALSE" when using this excell formula?

When using this formula I get the correct answer. However, when I copy this down to the next blank cell I get "FALSE" but I want it to be blank. Not "BLANK" but empty.
=IF(ISNUMBER(E5),IF(D5="LONG",((H5I5)+(K5L5))-(E5F5),IF(D5="SHORT",(E5F5)-((H5I5)+(K5L5)))))
I have also tried these formulas with the same results:
=IF(D17="LONG",((H17I17)+(K17L17))-(E17F17),IF(D17="SHORT",(E17F17)-((H17I17)+(K17L17,””))))
=IF(D18="LONG",((H18I18)+(K18L18))-(E18F18),IF(D18="SHORT",(E18F18)-((H18I18)+(K18L18),"")))
Use this:
=IF(ISNUMBER(E5),IF(D5="LONG",((H5I5)+(K5L5))-(E5F5),IF(D5="SHORT",(E5F5)-((H5I5)+(K5L5)))), "")
I've just put blank quotes as output when the condition is FALSE.
You are missing the FALSE parameters, without this, considering the result of conditions, return FALSE. Try this:
=IF(ISNUMBER(E5),IF(D5="LONG",((H5I5)+(K5L5))-(E5F5),IF(D5="SHORT",(E5F5)-((H5I5)+(K5L5)),"")),"")

Excel IF statement is returning "FALSE"

I am trying to write a statement which will read the content of the adjacent cells and select a value depending on the results to punctuate a paragraph. Just like the below sentence is laid out.
Statement 1, Statement 2, Statement 3.
A comma is included if the next statement has content. A full stop is included if the next statement does not have content. Nothing is included if the next and previous statements do not have content. I have used the formula below, but the bit that's supposed to add the full stop is returning FALSE:
=IF(A1<>"",IF(C1<>"",", "),IF(A1<>"",IF(C1="",". "),IF(A1="",IF(C1="",""))))
What have I done wrong?
I believe you have overcomplicated your formula. For example you test up to 3 times if A1 is blank
Are you trying to achieve this ?
=IF(A1<>"",IF(C1<>"","; ",""),IF(C1="",". ",""))
if A1 is not blank and C1 is not blank = ;
if A1 is not blank and C1 is blank = nothing
if A1 is blank and C1 is blank = .
if A1 is blank and C1 is not blank = nothing
The IF statement has this format: =IF(<Statement>, <Value_If_True>, <Value_If_False>)
If we break your code down in the same way, we get this:
=IF(<Statement1>, IF_TRUE1(<Statement2>, <Value_If_True2>), IF_FALSE1(<Statement3>, IF_TRUE3(<Statement4>, <Value_If_True4>), IF_FALSE3(<Statement5>, IF_TRUE5(<Statement6>, <Value_If_True6>))))
The missing <Value_If_False> will return FALSE by default.
Now, that might be a bit hard to read, so here's another layout:
Hopefully you can see all of the duplicate "question" nodes there - and also that the "." is impossible to reach, because it requires that A1<>"" is FALSE, and also TRUE.
Rewriting your code, there is still 1 "missing" terminator:
=IF(A1="", IF(C1="", "", FALSE), IF(C1="", ".", ", "))
(Or, if you want to be really fancy, use a CHOOSE statement:)
=CHOOSE(1+(A1="")+2*(C1=""), ", ", FALSE, ".", "")
This part of your formula seems redundant as it is already captured in the initial logical arguments:
IF(A1<>"",IF(C1="",". "),IF(A1="",IF(C1="","")))
I might not understand your objective entirely, but this should do the trick:
I'm assuming statements here are defined by inputs into columns A,B & C and column A has to be filled first.
=IF(A1="","",IF(AND(B1="",C1=""),". ",", "))
If I'm way off, do share your table/sheet structure with desired results.
Ok, had a go at this just to see:
=IF(AND(A1="",C1=""),"",IF(AND(A1<>"",C1<>""),A1&";"&C1,A1&C1&"."))
And if both are not blank, then they should be separated by ";" and finished with "." ...
=IF(AND(A1="",C1=""),"",IF(AND(A1<>"",C1<>""),A1&";"&C1&".",A1&C1&"."))
See:

IF Function Condition in Microsoft Excel

In excel, lets say I want to check if from A1 to A9 is equal to the value 10? How do I do it?
All I could think of is:
IF(A1:A9 = 10, "True", "False")
So what should I do to fix this?
Edit:
Since my question wasn't clear just now. I just want to know like...
IF(A1 = 10, True, False)
IF(A2 = 10, True, False)
IF(A3 = 10, True, False)
and so on...
For single cells to return TRUE or FALSE just type =A1=10 and drag down.
For your whole range at once, just try:
{=AND(EXACT(A1:A9;10))}
Notice it's an array formula entered through CtrlShiftEnter and will return TRUE or FALSE
You can test to see if any cell in A1:A9 contains a "10" using =CountIf():
=IF(COUNTIF(A1:A9, 10)>0, "True", "False")
If, instead, you wanted to know if the range summed to 10, you could stick Sum() in there (it's not clear from your question):
=IF(Sum(A1:A9)=10, "True", "False")
Not sure if you want all cells to be equal to 10, or any one cell to be equal, but here goes:
=IF(COUNTIF(A1:A9,10)=COUNT(A1:A9),TRUE,FALSE)
will show true if all values are 10.
This version will show if any one of the cells is equal to 10:
=IF(COUNTIF(A1:A9,10)>=1,TRUE,FALSE)
Checks whether the amount of cells equal to 10 are equal to amount of cells inside A1:A10
=IF(COUNTIF(A1:A9, 10) = ROWS(A1:A9), TRUE, FALSE)

Conditional Formatting - highlight cells where formula is different?

Is there a way via Conditional Formatting (preferably no VBA, but if it's a must, then I'm open to it), to highlight a cell where the formula "idea" is different than the cell above?
I have a column of formulas, but have to manually edit a few of those. I'd like to have those manually edited formulas highlighted, so when I change the formula for the other cells, I know which cell to skip when updating that column.
For example, here's my column and formulas:
I'd like to have B5 highlighted yellow, since the formula is different.
I've tried using =FORMULATEXT($B3)<>FORMULATEXT($B2) but that doesn't work, since it's looking at the literal formula text...in which has they're always different. (=FORMULATEXT(B3)=FORMULATEXT(B2) will always be FALSE since the formula is technically changing, despite it being the same "idea").
I could also perhaps use =LEN($B3)<>LEN($B2) but that would have a false positive when the row changes from 9to 10, and again from 99 to 100...
The other option would, of course, just be to work in an IF()statement to clarify why I'm doing a different formula, i.e. =IF(ROW()=5,A5+A4+A2+A1,A5+A4) and use that...but there's no real logic for why I have to edit manually I could work in - which is why I'd just like a nice visual reminder on those random cells that the formula isn't like the others.
Edit: Quick note that the above formulas are way simplified. My actual ones are a little complex. I'm looking for a general answer to this too. Just thinking for my purposes, I could maybe do a check that if the formula has more than two + in it, highlight the cell. ...but I'm interested in a general way to solve this type of issue that could apply more broadly.
Here's another option for UDF:
Function findDifferent(Rng As Range) As Boolean
findDifferent = Not (Rng.FormulaR1C1 = Rng.Offset(-1).FormulaR1C1 Or Rng.FormulaR1C1 = Rng.Offset(1).FormulaR1C1)
End Function
Here's a quick VB aided solution I came up with. If I add a comment to the special cells (which I do to explain the formula/why it's different), I can check for a comment then highlight it.
Add this function to the workbook:
Function has_Comment(cel As Range) As Boolean
has_Comment = False
If cel.Comment.Text <> "" Then
has_Comment = True
End If
End Function
Then a simple Conditional Formatting formula of:
=has_comment(B2)
That works, and is relatively simple.
Edit: I found also you can do this, which doesn't rely on a comment. Just points out an Inconsistency Error.
Function has_inconsistency(cel As Range) As Boolean
has_inconsistency = False
If cel.Errors.Item(xlInconsistentFormula).Value = True Then
has_inconsistency = True
End If
End Function

In Excel, how can I avoid repeating a big part of the formula just to check if the return value is blank?

I have a situation where I am referencing cells in a different worksheet and returning the values of cells from that worksheet. Although it works, I find my current method inefficient because I have to repeat the formula in the logical test part of the IF statement:
=IF(**EXTREMELY LONG COMPLICATED FORMULA** <> "", **EXTREMELY LONG COMPLICATED FORMULA**, "")
As you can see, I must repeat the main part of the formula just to check if it is blank first. If I do not do this, I get a zero in the cell (for blank values in the referenced worksheet). I'm looking for something more like:
=IF(**EXTREMELY LONG COMPLICATED FORMULA** <> "", **RETURN VALUE**, "")
This looks cleaner to me because I won't have to repeat myself. Also, if we ever have to update the formula, I won't have to duplicate my changes to the repeated parts. Is there a way to do this?
The above is actually a simplified version of my problem, but the answer should get me where I need to go. My actual formula has nested IF statements checking along the way for blanks. For reference, here it is:
=IFERROR(IF(SMALL(IF(ImportedData!$H$2:$H$1000>=DataFilters!$A$1,IF(ImportedData!$G$2:$G$1000=DataFilters!$A$15,ROW(ImportedData!A$2:A$1000)-ROW(ImportedData!A$2)+1)),ROWS(ImportedData!A$2:ImportedData!A2))<>"",IF(INDEX(ImportedData!A$2:A$1000,SMALL(IF(ImportedData!$H$2:$H$1000>=DataFilters!$A$1,IF(ImportedData!$G$2:$G$1000=DataFilters!$A$15,ROW(ImportedData!A$2:A$1000)-ROW(ImportedData!A$2)+1)),ROWS(ImportedData!A$2:ImportedData!A2)))<>"",INDEX(ImportedData!A$2:A$1000,SMALL(IF(ImportedData!$H$2:$H$1000>=DataFilters!$A$1,IF(ImportedData!$G$2:$G$1000=DataFilters!$A$15,ROW(ImportedData!A$2:A$1000)-ROW(ImportedData!A$2)+1)),ROWS(ImportedData!A$2:ImportedData!A2))),""),""),"")
The most obvious solution is to use a helper column or cell. Just put EXTREMELY LONG COMPLICATED FORMULA somewhere in your spreadsheet, then refer to that cell in your IF formula.
Edit
To avoid a helper column, here is a trick I've used on occasion:
=IFERROR(VALUE(long_formula&""),"")
What this does is, concatenate the result of long formula with an empty string (which converts it to a string), then take the value of all that (which converts it back to a number if possible), then substitute any errors with a blank. (An error would occur if you attempt to take the value of something that's not numerical.)
This will only work if you either have a numerical result or an empty result. It will fail if you have a text result.
As of March 2020, Excel includes the LET function. You can write:
=LET(ELCF,**EXTREMELY LONG COMPLICATED FORMULA**,IF(ELCF <> "", ELCF, ""))
Where the three parameters are:
the name you will use to refer to your calculation,
the calculation itself, and
the final formula using the calculation.
The function also allows for multiple names to be defined. The general syntax is:
=LET(name1, name_value1, calculation_or_name2, [name_value2, calculation_or_name3...])
https://support.microsoft.com/en-us/office/let-function-34842dd8-b92b-4d3f-b325-b8b8f9908999
Do you need the blank in the cell for further calulations or if-functions or Do you just dont want to see the 0s?
Second case:
Just use a number format for the column like
0,00;-0,00;"";#
First case:
Put the following code in a module:
Option Explicit
Public Function IfEmpty(LongFormula As String) As String
If LongFormula = "" Then
IfEmpty = ""
Else
IfEmpty = LongFormula
End If
End Function
And use it in your worksheet like
=IfEmpty(**EXTREMELY LONG COMPLICATED FORMULA**)

Resources