EnterKey to press button in VBA Userform

后端 未结 6 949
春和景丽
春和景丽 2020-12-31 04:45

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 <

6条回答
  •  隐瞒了意图╮
    2020-12-31 05:28

    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

提交回复
热议问题