Add ISBLANK validation before comparing values - excel

Actually I am not much familiar with Excel formulas.
I am using dates from Column E and F to color cells
=+IF(AND(DATEVALUE(I1)>=DATEVALUE($E$2);DATEVALUE(I1)<=DATEVALUE($F$2));1;2)
This formula is working fine when there is value present for column E and F.
if there is no value present for E and F it results error value.
I know little bit about ISBLANK() function.
I want to add condition to check cell E2 and F2 are not blank before my existing formula. Can you please suggest the proper syntax?
Thanks

You need to wrap your current operations in a function that checks each cell. If either of them is blank, you probably want to return "", or else the IF will automatically return FALSE.
You could use a chain of ifs, but since ISBLANK returns a boolean we can instead use an OR.
OR(ISBLANK($E$2),ISBLANK($F$2))
will return TRUE if either of the two cells is blank, so you'll need to put your operations into the False option, giving us:
=IF(OR(ISBLANK($E$2),ISBLANK($F$2)),"",IF(AND(DATEVALUE(I1)>=DATEVALUE($E$2),DATEVALUE(I1)<=DATEVALUE($F$2)),1,2))
Although you seem to have strange syntax, probably down to language settings or something, so you may prefer this:
=+IF(OR(ISBLANK($E$2),ISBLANK($F$2));"";IF(AND(DATEVALUE(I1)>=DATEVALUE($E$2);DATEVALUE(I1)<=DATEVALUE($F$2));1;2))

Use this condition which will ensure that both are not blank:
IF(OR(ISBLANK($E$2),ISBLANK*($F$2), your operations, "")

Thanks to all for your suggestions and valuable time.
But after reading some office.com documentation I find a proper solution.
IFERROR is more suitable than ISBLANK for my problem
instead of checking for blank cells I directly apply DATEVALUE() on cell . so if there is a blank cell DATEVALUE() return error and IFERROR() condition set value 2.
=+IF(AND(DATEVALUE(G1)>=IFERROR(DATEVALUE($E$7),0),DATEVALUE(G1)<=IFERROR(DATEVALUE($F$7),0)),1,2)

Related

Excel: Find particular (text) value in range

I'm struggling with something I think should be easy, it seems to be a common problem, I've found another solution here on the website but it won't work here in my document.
I want to find the (exact) value into a range, and having a true or false result if this value was found.
I tried with the combination of the find, isnumber and sumproduct formula but the value is never found, if I use a nested if formula it's working.
I have a dutch version of Excel, that's why you see "onwaar / waar" but onwaar is "false" and waar is "true".
Also my formula is written in dutch, but I translated it through the Excel-Translator.de website, I'm not 100% sure if it's done correctly.
In cell F2 I have this formula:
=SUMPRODUCT(SUMIF(E2, $A$2:$A$11))>0
In cell G2 I have this formula:
=IF(E2=$A$2,TRUE,
IF(E2=$A$3,TRUE,
IF(E2=$A$4,TRUE,
IF(E2=$A$5,TRUE,
IF(E2=$A$6,TRUE,
IF(E2=$A$7,TRUE,
IF(E2=$A$8,TRUE,
IF(E2=$A$9,TRUE,
IF(E2=$A$10,TRUE,
IF(E2=$A$11,TRUE,FALSE))))))))))
Thanks for your help.
First use function =COUNTIF($E$2:$E$11,A2) to know if the search value column contains your value.
Then, use function =IF(F2>=1,"True","False") determine true or false.
Combined, yout get =IF((COUNTIF($E$2:$E$11,A2)),"True","False")
screenshot of working example

condition formatting based on formula's result

I have a cell (AP21) containing a formula, and I want that the AP22 become black if the AP21 return empty string.
I am using conditionnal formatting but I not able to do that, because when I am using a formula to check the value of AP21, it's always considered as not empty because it contains a formula and not a text.
What I need is to evaluate in my AP22 the result of the formula of the cell AP21 and not the formula itself.
Any clue about how to do that please ?
Here is what I have to help you to understand me more
I tried also what is suggested in comments still didn't work
As #BigBen said in comments, you want to compare to an empty string
=$AP21=""

Excel: Using ISBLANK in conjunction with IF statement

I am trying to develop a simple expiration date with conditional highlighting. I've set up the column I to an IF statement based on a logic test in column G, drawing value from Column A. Formula is currently:
=IF(G2="N", A2+7,A2+60)
Problem is, I'm making this for a complete excel newbie so I need it foolproof. I want column I to remain blank as long as either cells in the corresponding column A or G are blank (not relevant which, they'll both be filled together). I've tried a few nested and "AND" statements to no avail.
You need to use OR to test if either A2 or G2 is blank using the ISBLANK function:
=IF(OR(ISBLANK(A2),ISBLANK(G2)),"",IF(G2="N",A2+7,A2+60))
If so, you can return "" if either input is blank, and if both are populated then go ahead and use your original formula.
One option is to use COUNTA function to determine how many cells are populated and only use the IF function if the result is 2, e.g.
=IF(COUNTA(A2,G2)=2,IF(G2="N",A2+7,A2+60),"")

IF function with two cell ranges

I have two sheets with the same line of cells, for example, A1:A5.
I need to check if the value of every cell in Sheet1!A1:A5 is equal to Sheet2!A1:A5 but the hitch is the values will be letters, and all values are different. Simply typing the formula got me a #VALUE! error.
I know I can just write the formula:
=IF(Sheet1!A1=Sheet2!A1;1;0)
and then simply retype it in a number of cells with different values, but I'm looking for a way to shorten the formula.
Any suggestions?
To shorten the formula use array function. With that you will be able to check the whole range at once.
=IF(AND(Sheet1!A1:A5=Sheet2!A1:A5);1;0)
After typing the formula press Ctrl+Shift+Enter instead of just Enter key to confirm array formula.
This one is a little shorter
=(Sheet1!$A1=Sheet2!$A1)
You could use
AND(EXACT(Sheet1!A1, Sheet2!A1), EXACT(Sheet1!A2, Sheet2!A2), EXACT(Sheet1!A3, Sheet2!A3), EXACT(Sheet1!A4, Sheet2!A4), EXACT(Sheet1!A5, Sheet2!A5))
But in the following way:
Have a separate column with the code (let's say, column G)
EXACT(Sheet1!$A1, Sheet2!$A2)
To the column next to that, have a single cell with the code
AND(G1:G5)
Use the AND() function:
IF(AND(Sheet1!A1=Sheet2!A1,Sheet1!A2=Sheet2!A2,Sheet1!A3=Sheet2!A3,Sheet1!A4=Sheet2!A4,Sheet1!A5=Sheet2!A5),1,0).
EDIT
Not realy sure about your aim,
If you want it short because it is too difficult to write the above function, then try the method below:
=IF(CONCATENATE(Sheet2!A1,Sheet2!B1,Sheet2!C1,Sheet2!D1,Sheet2!E1)=CONCATENATE(Sheet1!A1,Sheet1!B1,Sheet1!C1,Sheet1!D1,Sheet1!E1),1,0)
But this is not without catch, it could return false positive. So use it with care. To overcome the false positive, I could only make the formula longer (but still relatively easy to write out).
=IF(CONCATENATE(Sheet2!A1,"|",Sheet2!B1,"|",Sheet2!C1,"|",Sheet2!D1,"|",Sheet2!E1)=CONCATENATE(Sheet1!A1,"|",Sheet1!B1,"|",Sheet1!C1,"|",Sheet1!D1,"|",Sheet1!E1),1,0)

Is it possible to combine AND() and OR() in Excel formulae?

Is there an easy way to combine AND() and OR() within Excel formulae. IE:
IF(OR(AND(A2="",B2=""),AND(A2="(blank)",B2="(blank)")),"BLANK","NOT BLANK")
Or do you need to use nesting to achieve the same end goal?
If you're a programmer, this synax might appeal more to you:
=IF((A2="")*(B2="")+(A2="(blank)")*(B2="(blank)"),"BLANK","NOT BLANK")
If you actually need to check some arbitrarily sized range, whether it's empty (using "(blank)" as an alias for empty value), you might use this formula instead:
=IF(COUNTIF(CheckedRange,"(blank)")=COUNTA(CheckedRange),"BLANK","NOT BLANK")
you can easily extend the list of empty value aliases by just adding more COUNTIFS
The formula you provided is valid and works.
Also, in the formula you posted, you are already using nesting (the AND is nested within the OR).
On a side note, the fomula will only work if both A2 and B2 are blank, or if A2 and B2 are both set to (blank). A potentially better formula for what you're trying to do is AND() first then OR() like this:
=IF(AND(OR(A2="", A2="(blank)"), OR(B2="", B2="(blank)")), "BLANK", "NOT BLANK")
With this new formula, you would get the result BLANK if A2 is empty, and B2 is (blank), and vice versa.

Resources