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

All Answers

Answers by Expert:


Ask Experts

Volunteer


Tom Ogilvy

Expertise

Worked with the program for many years - provided assistance on MS Excel Newsgroups since 1997. Have received the Microsoft MVP award annually since 1999. I don't answer questions on using Excel in a browser Since I have no way to test this. Prefer not to answer charting questions. I consider myself to be particularly knowledgeable about using VBA internal to Excel but have no problems with formulas and pivot tables either.

Experience

Have Used Excel for 15 - 20 years. Answered in excess of 70,000 Excel related questions in MS Excel newsgroups. Unless obvious, please specify whether you want a worksheet function or macro/VBA solution.

Education/Credentials
BS General Engineering (concentration in Industrial Engineering) MS Operations Research Systems Analysis

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