I have a userform in Excel that asks for a username and password. Once you enter your password if you press Enter it just \"selects\" the next item which is the <
Further to @Penn's comment, and in case the link breaks, you can also achieve this by setting the Default
property of the button to True
(you can set this in the properties window, open by hitting F4)
That way whenever Return is hit, VBA knows to activate the button's click event. Similarly setting the Cancel
property of a button to True
would cause that button's click event to run whenever ESC key is hit (useful for gracefully exiting the Userform)
Source: Olivier Jacot-Descombes's answer accessible here https://stackoverflow.com/a/22793040/6609896