2 Questions...

Nigel Martin

Board Regular
Joined
Feb 17, 2002
Messages
133
I am a total novice on UserForms. I have managed to create a UserForm that works with a TextBox and 2 CommandButtons on it. When I hit the enter key after typing a login pasword into the TextBox it highlights the OK CommandButton. How do I make the enter key do the same as clicking on the OK button ? Question 2 - I want a cell to say "Good Morning" if it is AM, "Good Afternoon" if it is PM and "Good Evening" if it is between 17:00 and 00:00 What formula do I need ?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi,

Answer 1:
You might want to set the OK button's default equals to TRUE. I believe that will work.

Answer 2:
If Hour(Now()) >= 12 And Hour(Now()) < 17 Then MsgBox ("Good Afternoon")
If Hour(Now()) >= 8 And Hour(Now()) < 12 Then MsgBox ("Good Morning")
If Hour(Now()) >= 17 And Hour(Now()) < 24 Then MsgBox ("Good Evening")
If Hour(Now()) < 8 Then MsgBox ("You shouldn't be working")

The codes above is to identify the time of the day, hour especially.

HTH
 
Upvote 0
Many thanks - the answer to my first question works well but I have not got the time to try answer 2 at the moment but I'm it will be OK.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top