+ Reply to Thread
Results 1 to 14 of 14

Leaving a cell blank unless referenced cells contain a value

  1. #1
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Leaving a cell blank unless referenced cells contain a value

    Hi all,

    This is my first post to the forum, although I have been a long-time 'lurker'. The knowledge base here is pretty impressive, so I know I'm in good hands!

    So here is my problem: I am working on a new time-card for our accounting team. I have the basic format laid out, and my formulas are working fine. However on my daily hours total it shows a '12' in that cell, when I would like to leave it blank. How can I leave this cell blank unless the cells that it references contain a value? My formula is below:

    =IF(D16="","",((12-D16)+E16+G16+H16)-F16)

    D16 = DAILY START TIME
    E16 = DAILY END TIME
    G16 = ANY VACATION HOURS TO BE USED
    H16 = ANY PERSONAL HOURS TO BE USED
    F16 = TOTAL TIME TAKEN FOR A MEAL PERIOD

    Any assistance will be greatly appreciated.

    Regards,

    -dparkhill

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Leaving a cell blank unless referenced cells contain a value

    In what cell are you getting 12. I cannot quite follow.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Leaving a cell blank unless referenced cells contain a value

    Sorry about that.

    The formula is in cell I16, which totals the hours worked during the week. and that is where I am getting the '12'.

    I have attached a copy of my spreadsheet for reference - see below.

    TIME CARD - REF.xlsx

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: Leaving a cell blank unless referenced cells contain a value

    Change your formula to: =IF(OR(D2="",D2=0),"",((12-D2)+E2+G2+H2)-F2)
    and copy down.

  5. #5
    Registered User
    Join Date
    07-31-2012
    Location
    Minnapolis
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Leaving a cell blank unless referenced cells contain a value

    Try this =IF(D2=0,0,((12-D2)+E2+G2+H2)-F2)

  6. #6
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Leaving a cell blank unless referenced cells contain a value

    Thank you, everyone.

    I implemented the 'OR' statement, and now the formatting looks great.

    Thanks again!

    - dparkhill

  7. #7
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Leaving a cell blank unless referenced cells contain a value

    OK, so now the problem is that the spreadsheet is interpreting the time input incorrectly - 12pm for 12am, for instance. I tried changing the formatting from number to time, but that did not work. I also tried various adjustments to the formula, but again no luck.

    I searched the Excel Forum database for help, but came up empty.

    I have included a copy of the spreadsheet 'in use', so to speak as an example. Please see below.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-31-2012
    Location
    Minnapolis
    MS-Off Ver
    Excel 2010
    Posts
    31

    Re: Leaving a cell blank unless referenced cells contain a value

    TIME CARD - REF.xlsx

    is this kind of what you are looking for?

  9. #9
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Leaving a cell blank unless referenced cells contain a value

    It is, and it isn't...

    I come from a solid military/law enforcement background, so I use a 24hr time format anyway - but the people I work with do not. Ergo, once I unleash the dreaded 'military time' on them, they will freak out.

    I guess my real question now is why does Excel have such a hard time with 12pm? I know that the problem lies in how Excel is interpreting my formula (garbage in/garbage out), but I just cannot think of another way to draw up the formula...

  10. #10
    Registered User
    Join Date
    02-04-2013
    Location
    Saint Paul, MN
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Leaving a cell blank unless referenced cells contain a value

    would this be something better?

    they would have to enter the time with the am and pm, and then figure out what decimal value is needed for their lunch/vacation/PTO is, but it also puts the total hours worked into decimal value which would make one less step in payroll.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-04-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Leaving a cell blank unless referenced cells contain a value

    Hi

    if you set cells D17:I22 to custom format H:mm
    Adjust the formula to =if(D17="",0(E17-D17)-F17+G17+H17)
    Format the total in cell I23 to [h]:mm
    this will set the time card to normal clock not 24 hour
    thus 12 pm will be 12:00 and 12 am will be 00:00

    hope this helps

  12. #12
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Leaving a cell blank unless referenced cells contain a value

    All,

    Thank you for taking the time to assist me with this.

    I have attached a sanitized copy of the workbook for reference; In the final version, there will be validated data lists for employees, managers, and departments - I have removed those tabs from the workbook for this evolution. I have placed notes in column J for reference.

    Cell C-D6 takes the week ending, and automatically populates cells C11-18, and C22-28 for the reporting period.

    When I format the cell with custom format h:mm, I also get a date in the formula bar preceding the time.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    02-04-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: Leaving a cell blank unless referenced cells contain a value

    Hi
    Your time card is looking good

    Just a thought to stop time being entered incorrectly, you could set up a data validation just for the start/finish times. the user would then just have to click on a start/finish cell and from the drop down list click on the time wanted. Have attached a small sample file for you to look at

    if you need instructions to do this just give me a shout
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    02-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Leaving a cell blank unless referenced cells contain a value

    Wow, that is pretty simple. Thank you!

    I'm going to give that a shot. I will have to use 1/4 hours, but that will be fine.

    I guess I have just been over-thinking this...

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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