+ Reply to Thread
Results 1 to 10 of 10

Making a function to output a String name based on a reference of a cell with a time in it

  1. #1
    Registered User
    Join Date
    11-18-2010
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    41

    Making a function to output a String name based on a reference of a cell with a time in it

    Hi,

    I have a long nested if statement that I feel like would be better as a function. At my company, employees' shifts are from 6AM to 6PM and the next shift is from 6PM to 6AM. I want to create a function where the input is a date and time, and the output is the name of the supervisor of that shift at that time. I'm not sure where to start. I looked at using cases but not sure how to reference the input date and time cell.

    Thank you

  2. #2
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Making a function to output a String name based on a reference of a cell with a time i

    how is this data stored? or did you just hard code it into your if statement? If it was me making this, i would make another sheet and create a small database with the shift times and supervisors names. this way you can make a vlookup formula to lookup the time you specified in cell a and return the supervisor in cell b

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Making a function to output a String name based on a reference of a cell with a time i

    if you really wanted this done in vba i would need to know what the format you want is for the input. like MM/DD/YYYY HH:MM:SS.

  4. #4
    Registered User
    Join Date
    11-18-2010
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Making a function to output a String name based on a reference of a cell with a time i

    Give me a few minutes and I'll attach a file and you can see what i've done

  5. #5
    Registered User
    Join Date
    11-18-2010
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Making a function to output a String name based on a reference of a cell with a time i

    ShiftFunction.xlsm

    So in that file you should be able to see the if statement I have, but in my larger sheet I'm going to need to output who's on shift based on time from another cell. If you have questions let me know, I know it might be somewhat confusing

  6. #6
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Making a function to output a String name based on a reference of a cell with a time i

    Look at this and see what you think
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    11-18-2010
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Making a function to output a String name based on a reference of a cell with a time i

    Hmm, that helps a little, but I'm looking more for something that can recognize my time input, whether it be 1:33 AM or 3:45 PM and know which person is on shift

  8. #8
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Making a function to output a String name based on a reference of a cell with a time i

    Here you go try this
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    10-08-2010
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    386

    Re: Making a function to output a String name based on a reference of a cell with a time i

    oops,,,ok paste this into the cell where the name pops up (it might say false if you type in lets say 12:55 AM or so

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-18-2010
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    41

    Re: Making a function to output a String name based on a reference of a cell with a time i

    alrighty I think I can work with that, thanks for your help!

+ 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