title: Assigning hotkeys to buttons on forms created for excel vba
body: <p>I have created a macro for excel which will pop up form that contains button and text field. Is there a way to assign hotkeys such as 'ctrl+Enter' or 'F12' to the buttons? The hotkey should work regardless of which field or button the focus is on. </p>
  
  <p>(so far I have managed to create buttons/fields_Keydowns to check MSForms.ReturnInteger for vbKeyF12, but I have to do that for every field and button, is there an easier way?)  </p>
  
  <p>Say, I have 2 things on the form, button "CommandButton1" and textfield "TextBox1"</p>
  
  <p>code for the button:</p>
  
  <pre><code>Private Sub CommandButton1_click()
  ActiveCell.FormulaR1C1 = UserForm1.TextBox1.Text 
  End Sub
  </code></pre>
  
  <p>The hotkey will be useful when I add in more fields and buttons...</p>
  
  <p>Also how do i set the 'Escape' button to close/hide the form ?</p>