column V is homework actual finish date
column W is required finish date
condition 1: if V is not blank, return value "ok"
condition 2: if "V is blank" and "W is blank", return value "ok"
condition 3: if "V is blank" and "W>=today()", return value "overdue"
I'm only able to combine condition 1 and 3 in my IF formula:
=IF(NOT(ISBLANK(V2)),"ok",IF(W2<=TODAY(),"over due","ok"))
Could anybody help me add condition two into my formula?
thanks for everybody's help/ im really new to stackoverflow.
and i have already learned something from everybody.
btw i made a typo in my condition 3, it should be "W<=today()" instead "W>=today()"
thanks
=if( and( not(isblank(v2)), not(isblank(w2)) ), "ok",
if( not(isblank(v2)), "ok",
if( and( isblank(v2), w2 >= today() ), "overdue", "ok" )
)
)
Paste this directly into the formula box and see how it works.
Let me see;
Your decision tree is missing one possible output; when V is blank, W !is blank and W<=today()
once you tell us what output means to you, we can easily help you.
Try this.
=IF(NOT(ISBLANK(V2)),"ok",IF(ISBLANK(W2), "ok",IF(AND(ISBLANK(V2),W2 >= TODAY()),"Over Due", "Error")))
As tip for future macros, try building them up a little at a time. For IF statements it can get tricky but this may help.
Write the first condition like this with 'Other Value' as a place holder.
=IF(NOT(ISBLANK(V2)),"ok","Other Value")
Once you have that bit working the way you like it then put in the false condition like this.
=IF(NOT(ISBLANK(V2)),"ok",IF(ISBLANK(W2),"ok","Other Value"))
And then finally add your last condition.
This is quite simple with one AND statement. First, redefine the logic you need for yourself: there are only two outcomes you care about: an assignment is unfinished and overdue, OR an assignment is finished/not yet due. So to write our IF statement, check only whether the assignment is unifinished and overdue. In any other case, the status will be the same.
Edit per comment
=IF(AND(ISBLANK(V1),W1<=TODAY(),W1>1),"overdue","ok")
Related
My table in excel
=IF(ISBLANK(F2),"INPUT CHECK DUE",IF([#[CHECK DUE]]<=TODAY(),"FOR DEPOSIT",([#[CHECK DUE]]-TODAY()&" Day(s) remaining")))
and above is my code on status Column. Now I am trying to incorporate a function that would change the status from FOR DEPOSIT to DEPOSITED whenever the remarks column is filled out. Can anybody help or give idea please. Thank you.
Can't you just nest it inside another IF?
=IF(ISBLANK(F2),"INPUT CHECK DUE",IF([#[CHECK DUE]]<=TODAY(),IF([#[remarks]<>"","DEPOSITED","FOR DEPOSIT"),([#[CHECK DUE]]-TODAY()&" Day(s) remaining")))
i.e.
=IF(ISBLANK(F2),
"INPUT CHECK DUE",
IF([#[CHECK DUE]]<=TODAY(),
IF([#[remarks]<>"",
"DEPOSITED",
"FOR DEPOSIT"
),
([#[CHECK DUE]]-TODAY()&" Day(s) remaining")
)
)
I have an excel table see attached picture. I want to find which cells (rows) contain specific hours. To do so I used the if function:
=IF(B2=HOUR("12:00:00");"xx";"yes")
The outcome was not correct. As you can see the outcome was "yes" corresponding to false.. What is the problem ?
In addition, I tried to embed the "and" function, in order to select multiple hours, but the excel prompt error message. The formula I tried in cell B2 is:
=IF(B2=HOUR(AND("12:00:00";"3:00:00");"xx";"yes"))
error message:
contain many conditions
I think you have swapped the arguments in your comparison.
According to the documentation
[HOUR] returns the hour of a time value
If we evaluate your formula step by step, we get:
HOUR("12:00:00") -> 12
B2 = 12 -> false
IF(false; "xx"; "yes") -> yes
To fix this, change your condition to HOUR(B2) = 12.
That should work for a single hour.
If you want to check for multiple hour values, you can use the OR function, as noted in a previous answer, but with modified conditions like this:
IF(OR(HOUR(B2) = 3; HOUR(B2) = 12); "xx"; "yes")
First you just have misplaced the return of the true and the return of the false. Try :
=IF(B2=HOUR("12:00:00");"yes";"xx")
Second, you do not want a logical and but a logical or. And your condition is "if B2 is an hour that is equals to '12:00 and 3:00'" this has no sense. What you want is "if B2 is an hour that is equals to '12:00' or B2 is an hour that is equals to '3:00'". This should look like :
=IF(OR(B2=HOUR("12:00:00"), B2=HOUR("3:00:00")) ; "yes"; "xx"))
Edit : Thanks to Korrat answer I can correct mine. The hour should not be compared like this. You should use the function HOUR on the cell and not on the value.
=IF(OR(HOUR(B2)=12, HOUR(B2)=3) ; "yes"; "xx"))
I am using this formula:
IF((AND(H11<>"",L11<>""),"Both",IF(AND(H11<>"",L11=""),"First"),IF(AND(H11="",L11<>""),"Second"))
I have two columns, if both columns are filled then write 'Both' in the 3rd column, if the first column is filled but the second is blank then label the 3rd column 'First', if the First column is blank and the second is filled then label the third column as 'Second'
What am I doing wrong here?
My error shows the following:
Any help would be appreciated.
THANKS!
As I mentioned in my comment above your Parentheses are all over the place. You open some and close them at random places elsewhere. You really have to spend the time to step through complex statements like this and insure that you have your parentheses properly lined up.
I think this should work for you:
IF(AND(H11<>"",L11<>""),"Both",IF(AND(H11<>"",L11=""),"First",IF(AND(H11="",L11<>""),"Second")))
I like to use a program like Notepad++ that will highlight matching parentheses when you hover over one:
For instance, hovering over the second parentheses just before that first AND() you will see that the closing parentheses is WAY at the back of the statement. Surely that doesn't make sense since that first parentheses in the statement would have to occur after it.
When I get in a real pickle with nested parenthetical statements like this I like to rewrite it using new-lines and indentation. It highlights issues pretty quick:
IF(
(
AND(
H11<>"",
L11<>""
),
"Both",
IF(
AND(
H11<>"",
L11=""
),
"First"
),
IF(
AND(
H11="",
L11<>""
),
"Second"
)
)
And you can see, again, that there is stuff that isn't where it belongs and at least one of the opening parentheses is lacking it's closing parentheses.
The structure should be like the following. The original formula has several errors, 2nd and 3rd IF do not have valuse for false
IF(
(AND(H11<>"",L11<>""),
"Both",
IF(
AND(H11<>"",L11=""),
"First",
IF(
AND(H11="",L11<>""),
"Second",
"none"
)
)
)
I have the following formula:
=IF(AND(A1=0,A3="","1 item"),
IF(AND(A1=0,A3="Exclude","1 item"),
IF(AND(A1=1,A3="Exclude","1 item","2 items"))))
3 combinations of cell values in A1 and A3 return text which I'm calling "1 item"
Only 1 combination of cells value returns text which I'm calling "2 items".
The only combination to return "2 items" is where A1=1 AND A3="".
The formatting is wrong but I'm not sure where.
Any help would be greatly appreciated.
this is the correct formula -
brackets of AND() were not properly closed.
=IF(AND(A1=0,A3=""),"1 item",IF(AND(A1=0,A3="Exclude"),"1 item",IF(AND(A1=1,A3="Exclude"),"1 item","2 items")))
Excel's IF expects three parameters: Condition, What to do if condition is TRUE, and what to do if condition is FALSE.
I'll re-format your formula so you can see where the error is:
IF( AND(A1=0,A3="","1 item") ,
IF(AND(A1=0,A3="Exclude","1 item"),
IF(AND(A1=1,A3="Exclude","1 item","2 items")
)
)
)
As you can see
For the first IF you are not providing what to do if condition is FALSE,
The same for the second IF,
The third IF has no definition of what to do if the condition is TRUE or FALSE.
Hope this helps you.
UPDATE
Following your comment (which is still not clear to me), hereinafter I'm providing simple rules you may use to construct your formula correctly:
Write your formula as a piece of text (like the example I show above) so that you can easily read, edit and verify it,
Remember that Excel's IF has three parameters: Condition, result when condition is TRUE and result when condition is FALSE,
Within any of these three parameters, you can include whatever you want PROVIDED that the result is compliant with what the function expects for that parameter; for instance, writing for the first parameter 3=8 is completely legal since the result is FALSE (while 4=2*2 would yield TRUE).
Having this in mind, here is the formula I think you are looking for (WARNING!!! I'm not sure I understood what you need, but if not, changing it should be very easy for you now):
IF(AND(A1=1,A3=""),"2 items","1 item")
This is based on your wording: The only combination to return "2 items" is where A1=1 AND A3="".
I am trying to write a formula to include multiple criteria and can't seem to get it right.
The formula works as is however I need to include "SHOT10","SHOT20", "SH15" and "SH20"
=IF(AND(C5194="SHOT15",H5194="",I5194=""),E5194,"")
Can someone assist me with modifying the above formula?
The AND(C5194="SHOT15",H5194="",I5194="") is equivalent to saying:
C5194="SHOT15" And H5194="" And 15194=""
So what you have in VBA code is:
If C5194="SHOT15" And H5194="" And 15194="" Then
ActiveCell = E5194
Else
ActiveCell = ""
End
You can use AND( and OR( to specify different parameters.
For example, If I want to pickup 3 different values in 'A1', but make sure that 'B1' and 'C1' are blank, I can use:
=IF(AND(OR(A1="A",A1="B",A1="C"),B1="",C1=""),"True","False")
So in your case specifically:
The issue now is that I now need to also consider SHOT10, SHOT20, SH15 and SH20 as well. Meaning that if either SHOT15, SHOT10, SHOT20, SH15 or SH20 appears in C5194 and H5194 is blank and I5194 is also blank then return the value of E5194 else return blank. The key is that all the conditions must be met for the value of E5194 be returned
Your formula becomes:
=IF(AND(OR(C5194="SHOT15",C5194="SHOT10",C5194="SHOT20",C5194="SH15",C5194="SH20"),H5194="",I5194=""),E5194,"")
Edit: Shorten Using an array constant per barry houdini:
=IF(AND(OR(C5194={"SHOT15","SHOT10","SHOT20","SH15","SH20"}),H5194="",I5194=""),E5194,"")
=IF(
AND(
OR( C5194="SHOT10", C5194="SHOT15", C5194="SHOT20", C5194="SH15", C5194="SH20" ),
H5194="",
I5194=""
),
E5194,
""
)