Share via

Creating a string from time range

Anonymous
2017-06-26T21:48:21+00:00

Hi, 

I have to create a string variable for a range of time during the day:

02:00:00 - 05:59:00 is to be coded as "Early"

6:00:00 - 09:59:00 is to be coded as Morning

10 - 13:59 is to be coded as Noon

14 - 17:59 is to be coded as Afternoon

18- 21:59 is to be coded as Evening 

And finally 22:00:00 - 1:59 is to be coded as Night. 

Please help! (With full formula as I am relatively new to using IF statements with time values)

Thanks in advance.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

11 answers

Sort by: Most helpful
  1. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2017-06-26T23:25:07+00:00

    Hi,

    If will be a lengthy formula.  I have shown a screenshot as well.  Please retry.  If it still does not help, then upload your workbook to OneDrive/Google Drive and share the download link here.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-06-26T23:21:46+00:00

    Hi Ashish,

    Is there any way to make it simple. I am relatively new to solving such things on excel and have been using if statements in the past for such cases. Unfortunately I am getting the syntax wrong for this particular problem.

    Do you think, there is an If, Ifs statement that can work to solve this problem.

    thanks for your help!

    Was this answer helpful?

    0 comments No comments
  3. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2017-06-26T23:18:47+00:00

    Hi,

    If you have 1.1 million rows, you exceed the Excel row limit.  So, you can still get the correct result using Power Query.  However, sine the number of rows cannot be accommodated in a worksheet, we will have to transfer the result directly to the PowerPivot.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-06-26T23:14:53+00:00

    Is there any other way since my dataset has 1.1 million entries and Vlookup wont work

    Was this answer helpful?

    0 comments No comments
  5. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2017-06-26T23:08:02+00:00

    Hi,

    The formula in cell B10 is

    =IF(A10<=TIME(1,59,0),"Night",VLOOKUP(A10,$A$2:$B$7,2,1))

    Here's a screenshot

    Was this answer helpful?

    0 comments No comments