You are here:

Excel/Using IF statement

Advertisement


Question
QUESTION: I am trying to use the following statement,but I am having problems with times that cross the midnight boundary.

IF($D10>$E10,IF(AND($D10<=(BZ$9+1),($E10)>BZ$9),"X",""),IF(AND($D10<=BZ$9,$E10>BZ$9),"X",""))

Col D10 is the start time
Col E10 is the finish time
Col bz is the hour ie 00:00
Col bz10 is where the formula is



ANSWER: REG,
Try this:
=if(mod(BZ9-D10,1)<Mod(E10-D10,1),"X","")

this is applicable to elapsed periods less than 24 hours (but can go over midnight)

apply $ signs appropriate to your needs/layout.

--
Regards,
Tom Ogilvy


---------- FOLLOW-UP ----------

QUESTION: worked really well.however,i have just noticed it doesn't put an x in the start time.

Answer
I am not sure what is going on here.  I thought I just answered this, but

I am not sure what you mean by " it doesn't put an x in the start time."

If I make BZ9 match the start time, I get an X in BZ10.  If BZ9 is calculated, there could be slight differences between the start time and BZ9 and yet they display the same.   If you format each cell as General, you can see the underlying time serial number.  Otherwise, explain what you mean.  

--
Regards,
Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]

Experience

Extensive experience.

Education/Credentials
Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2012 About.com, a part of The New York Times Company. All rights reserved.