+ Reply to Thread
Results 1 to 7 of 7

Combining IF statement with regular formula...

  1. #1
    Registered User
    Join Date
    07-23-2009
    Location
    Des Moines, USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Exclamation Combining IF statement with regular formula...

    I am creating an electronic timesheet. I have created drop downs for times of the day, which then automatically calculates the number of hours worked based on the times selected. The trouble I am having is, I also need to incorporate "Vacation", "Sick Day", etc into the drop down box where the time of day is located.

    The sheet works great until someone selects a non-time related answer, such as "Vacation". When this option is selected, the cell that is supposed to contain the number of hours worked says #VALUE! when I, in fact, need it to list a value of 0 for the number of hours worked. Any idea on how to combine my formula =(D6-D5)*24+(D8-D7)*24+(D10-D9)*24 with an IF statement that will automatically assign a value of 0 if a text answer is selected from the drop down?

    Thank you in advance!
    Last edited by Story; 07-23-2009 at 01:13 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Combining IF statement with regular formula...

    =IF(ISNUMBER(X1),24*((D6-D5)+(D8-D7)+(D10-D9)),0)

    Where X1 is the drop down cell... adjust as needed.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    07-23-2009
    Location
    Des Moines, USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Combining IF statement with regular formula...

    =IF(ISNUMBER(D5),24*((D6-D5)+(D8-D7)+(D10-D9)),0) < This is a good start!

    The formula above works if a person from 1st shift chooses a start time [represented in cell D5] that is non numerical, such as "vacation" or "sick time". I believe I now need to combine this with a conditional OR statement so that it can also apply to a person from 2nd or 3rd shift's start time [represented by D7 and D9, respectively].

    What I REALLY need is for a cell containing text to be work a value of 0 because it is possible for someone to work hours in the morning, and then leave early as "sick" meaning the formula still needs to be able to calculate the number of hours actually worked. Right now, the formula would make the resulting calculation 0 if text is found anywhere in cells D5 through D10. I don't want to make the whole calculation 0 if text is found, but instead want just the cell containing text to be worth 0.

    Clear as Mud?
    Last edited by Story; 07-23-2009 at 11:38 AM. Reason: ERROR IN QUESTION

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Combining IF statement with regular formula...

    How about?

    =IF(SUM(D5,D7,D9),24*((D6-D5)+(D8-D7)+(D10-D9)),0)

  5. #5
    Registered User
    Join Date
    07-23-2009
    Location
    Des Moines, USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Combining IF statement with regular formula...

    That formula would not accomplish what I am attempting to do. It might be easier to answer if you can visualize the time sheet, which I have attached to this reply.

    For instance, 3rd shift is from 11pm - 7am. So, Monday's and Tuesday's schedule would be as follows (with Vacation being taken for Tuesday night's shift)

    Monday would be:

    Cell D5 would say 12:00 AM
    Cell D6 would say 07:00 AM
    Cell D7 would be BLANK
    Cell D8 would be BLANK
    Cell D9 would say 11:00 PM
    Cell D10 would be 11:59 PM
    Cell D11's calculation would be: "8" (Hours)

    Tuesday would be:

    Cell F5 would say 12:00 AM
    Cell F6 would say 07:00 AM
    Cell F7 would be BLANK
    Cell F8 would be BLANK
    Cell F9 would say VACATION
    Cell F10 would be BLANK
    Cell F11's calculation would be: "7" (Hours)

    Wednesday would be:
    Cell H5 would say VACATION
    Cell H6 would be BLANK
    Cell H7 would be BLANK
    Cell H8 would be BLANK
    Cell H9 would say 11:00 PM
    Cell H10 would be 11:59 PM
    Cell H11's calculation would be: "1" (Hours)

    Again, your help is GREATLY appreciated!
    Attached Images Attached Images

  6. #6
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Combining IF statement with regular formula...

    Try:

    =SUM(IF(SUM(D5:D6),D6-D5,0),IF(SUM(D7:D8),D8-D7,0),IF(SUM(D9:D10),D10-D9,0))*24

  7. #7
    Registered User
    Join Date
    07-23-2009
    Location
    Des Moines, USA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Combining IF statement with regular formula...

    FLAWLESS! I might have figured it out eventually, but you just saved me a TON of time. Thank you very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1