+ Reply to Thread
Results 1 to 13 of 13

Formula or Code to Convert Numbers to Text Based on Value

  1. #1
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Formula or Code to Convert Numbers to Text Based on Value

    Hi to all.

    if hour > 6 and < 12 = good morning
    if hour > 12 and < 17 = good afternoon
    if hour > 17 = good evenig

    with vba?
    xam
    Last edited by xam99; 10-28-2019 at 05:14 AM.

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: vba goodmorning

    How about
    Please Login or Register  to view this content.
    This needs to go in the "ThisWorkbook" module

  3. #3
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: vba goodmorning

    Hi fluff13 the macro work well.
    Thanks you.
    xam

  4. #4
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: vba goodmorning

    Thank you fluff13
    Last edited by xam99; 10-26-2019 at 05:55 PM.

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: formula good morning

    Formula Solution (moved from closed duplicate thread):

    The formula will go in cell M1:

    =IF(AND(L1>=6,L1<=12),"good morning",IF(L1<=17,"good afternoon",IF(L1<=20,"good evening",IF(OR(L1<6,L1>20),"good night",""))))

    If you have actual times in L1 rather than just numbers, you will need a different formula.

    Hope this helps.

    Pete
    Last edited by AliGW; 10-27-2019 at 03:43 AM.

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: vba goodmorning

    Quote Originally Posted by xam99 View Post
    Hi fluff13 the macro work well.
    Thanks you.
    xam
    You're welcome & thanks for the feedback

  7. #7
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: vba goodmorning

    Hi peteuk,
    your formula it is not so exact the 1/2/3/4/5 hours must be "good night"
    it must be like this

    1 Good night
    2 Good night
    3 Good night
    4 Good night
    5 Good night
    6 Good morning
    7 Good morning
    8 Good morning
    9 Good morning
    10 Good morning
    11 Good morning
    12 Good morning
    13 Good afternoon
    14 Good afternoon
    15 Good afternoon
    16 Good afternoon
    17 Good afternoon
    18 Good afternoon
    19 Good evening
    20 Good evening
    21 Good evening
    22 Good night
    23 Good night
    24 Good night
    0 Good night

    xam
    Last edited by xam99; 10-28-2019 at 04:18 AM.

  8. #8
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: vba goodmorning

    Nice and descriptive title. I seem to recognize someone's hand
    Last edited by Pepe Le Mokko; 10-28-2019 at 07:50 AM.

  9. #9
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: vba goodmorning

    I had put the thread to request a goodmorning formula
    but someone moved it here in the vba goodmorning thread

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,785

    Re: vba goodmorning

    You are completely missing the point!

    The reason the other thread was closed is because it was a duplicate of this one (same request essentially).

    This is about your inadequate thread title. I suggest you change the thread title to this: "Formula or Code to Convert Numbers to Text Based on Value".
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: vba goodmorning

    It just needs a slight re-arrangement of the formula in M1:

    =IF(OR(L1<6,L1>20),"good night",IF(AND(L1>=6,L1<=12),"good morning",IF(L1<=17,"good afternoon",IF(L1<=20,"good evening",""))))

    Copy down as required.

    Hope this helps.

    Pete

  12. #12
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: Formula or Code to Convert Numbers to Text Based on Value

    hello pete_uk now works.
    Thanks
    xam

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,785

    Re: Formula or Code to Convert Numbers to Text Based on Value

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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. HI! Magandang Umaga (Goodmorning!)
    By mikoski in forum Hello..Introduce yourself
    Replies: 3
    Last Post: 07-09-2014, 01:21 AM
  2. Goodmorning
    By fantilator in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 12-18-2012, 03:26 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