• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Textbox phrase according to time of day-

Joe Mazzone

New Member
I have 2 textboxes, Daytime and TextBox1

Daytime automatically gives the system time:
1718056757528.png
1718056775829.png
I need Textbox1 to do the following:

If the time in DayTime is from 00:00:00 AM to 11:59:00 AM, then let textbox1 say the following phrase: Good morning.

If the time in DayTime is 12:00:00 PM until 05:00:00 PM, then let textbox1 say the following phrase: Good afternoon

If the time in DayTime is 06:00:00 PM until 11:59:00 PM, then let textbox1 say the following phrase: Good evening

Is it possible to do this?
 

Attachments

  • DayTime.xlsm
    13.3 KB · Views: 2
An example :​
Code:
Private Sub UserForm_Initialize()
    DAYTIME = Format(Time, "H:MM AM/PM")
    TextBox1 = "Good " & IIf(Time < 0.5, "morning", IIf(Time < 0.75, "afternoon", "evening"))
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Back
Top