Hello,
I would like to get some grip on the syntax of a formula in excel 2007.
Logic is I want C2 to = "yes" if
B2's time is between 2 and 4 hours after A2's time.
Any help is much appreciated.
Hello,
I would like to get some grip on the syntax of a formula in excel 2007.
Logic is I want C2 to = "yes" if
B2's time is between 2 and 4 hours after A2's time.
Any help is much appreciated.
Assuming the times will be on the same day then try this
=IF(AND((B2-A2)*24>=2,(B2-A2)*24<=4),"Yes","No")
Audere est facere
Hello,
I keep getting a "missing then or go to" message:
I'm doing it in VBA though, and the code is:
I'm getting syntax error.![]()
Please Login or Register to view this content.
Last edited by Lifeseeker; 11-22-2011 at 06:22 PM.
Can anybody help on this please?
Minor correction:
The logic is:
If B2 is >=4, E2 will = "Yes" only if (C2 - A2) <=30 is true AND D2's time is between 2 and 4 hours after C2.
Otherwise, E2 will say "No"
Hi Lifeseeker
This is the entire code in your workbookAs you can see...there's a bit missing. There's an![]()
Please Login or Register to view this content.
missing and an![]()
Please Login or Register to view this content.
missing...not to mention...there's a reference to an "n" that's not defined. There's no way to trouble shoot this...not enough information...or code.![]()
Please Login or Register to view this content.
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Hi,
How about this version? I get no syntax error anymore, but it doesn't do the trick.
the logic is:![]()
Please Login or Register to view this content.
If B2 is >=4, E2 will = "Yes" only if (C2 - A2) <=30 is true AND D2's time is between 2 and 4 hours after C2. (this is an example of a row-level calculation)
"n" is time difference displayed in minutes?
Thanks
Can someone help with this please?
Can someone help?
hello
may be this approach
=IF(HOUR(A1-B1)>HOUR(2),"yes","")
try this also:
=IF(OR(HOUR(A1-B1)>2,HOUR(A1-B1)<=4),"yes","No")
Lifeseeker,
Attached is a modified version of your example workbook. Cell C2 didn't have an actual date because the "pm" was immediately next to the "12:30". VBA doesn't care, but formulas do. So here's VBA code for a Worksheet_Change event to perform as requested, and it will convert all dates entered incorrectly (like "7/4/11 12:30pm") to correct dates ("7/4/11 12:30:00 PM") and then check if E should be Yes or No in accordance to your logic stated above:
![]()
Please Login or Register to view this content.
Last edited by tigeravatar; 11-28-2011 at 01:00 PM.
Hope that helps,
~tigeravatar
Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks