+ Reply to Thread
Results 1 to 10 of 10

Assign time to categories (morning, afternoon, etc)

  1. #1
    Registered User
    Join Date
    06-30-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Microsoft 2013
    Posts
    35

    Assign time to categories (morning, afternoon, etc)

    Hello,

    Any suggestions for a formula that would take military time living in cell A2 and assign it to one of the categories below?

    4:00 - 11:59 = morning
    12:00 - 16:59 = afternoon
    17:00 - 21:59 = evening
    22:00 - 3:59 = night



    Thanks for the help!

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,088

    Re: Assign time to categories (morning, afternoon, etc)

    Try this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Never use Merged Cells in Excel

  3. #3
    Forum Expert dosydos's Avatar
    Join Date
    12-09-2015
    Location
    MA, USA
    MS-Off Ver
    365(PC) V:2412
    Posts
    1,477

    Re: Assign time to categories (morning, afternoon, etc)

    This should also work

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign time to categories (morning, afternoon, etc)

    Create the 2 column table in D1:E5...

    Data Range
    A
    B
    C
    D
    E
    1
    17:22
    Evening
    0:00
    Night
    2
    4:00
    Morning
    3
    12:00
    Afternoon
    4
    16:00
    Evening
    5
    ------
    ------
    ------
    22:00
    Night


    Then, this formula entered in B1:

    =LOOKUP(A1,D1:E5)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    06-30-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Microsoft 2013
    Posts
    35

    Re: Assign time to categories (morning, afternoon, etc)

    This works beautifully - thanks!

  6. #6
    Registered User
    Join Date
    06-30-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Microsoft 2013
    Posts
    35

    Re: Assign time to categories (morning, afternoon, etc)

    =IF(AND(A2>=0.166666667,A2<=0.4993056),"Morning",IF(AND(A2>=0.5,A2<=0.7076389),"Afternoon",IF(AND(A2>=0.708333333,A2<=0.9159722),"Evening",IF(AND(A2>=0.916666667,A2<=0.1659722),"Night",""))))

    Works great for all categories except for night for some reason which just returns a blank cell when formula is entered. I have midnight represented as 0:00, would that throw off the formula?

    Much thanks for the help!

  7. #7
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Assign time to categories (morning, afternoon, etc)

    You're welcome. Thanks for the feedback!

  8. #8
    Registered User
    Join Date
    06-30-2014
    Location
    Denver, Colorado
    MS-Off Ver
    Microsoft 2013
    Posts
    35

    Re: Assign time to categories (morning, afternoon, etc)

    All of the suggestions have worked! Thank you so much for your expertise :D

  9. #9
    Registered User
    Join Date
    06-29-2011
    Location
    london,england
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Assign time to categories (morning, afternoon, etc)

    = IF(HOUR(F2)>=20,"Night",IF(HOUR(F2)>=12,"Afternoon",IF(HOUR(F2)>=4,"Morning","Night")))

  10. #10
    Registered User
    Join Date
    01-14-2022
    Location
    Lagos, Nigeria
    MS-Off Ver
    Excel 2019
    Posts
    1

    Re: Assign time to categories (morning, afternoon, etc)

    This helped me, thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 6
    Last Post: 02-26-2020, 08:49 AM
  2. [SOLVED] assign values to categories
    By Neico in forum Excel General
    Replies: 3
    Last Post: 10-03-2013, 03:44 PM
  3. Morning, Afternoon and Evening
    By kungfool in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-28-2013, 01:31 PM
  4. [SOLVED] Assign Categories for Time of Day: "Morning", "Afternoon", "Evening"
    By long_shanks in forum Excel General
    Replies: 3
    Last Post: 06-11-2013, 02:59 AM
  5. Good morning/afternoon all.
    By NellyM64 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-16-2013, 07:38 AM
  6. Good morning, afternoon or evening .... Yes, I'm new.
    By mowens74 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 11-08-2012, 04:41 AM
  7. Replies: 3
    Last Post: 08-07-2011, 02:30 AM

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