title: Assign on-click VBA function to a dynamically created button on Excel Userform
body: <p>I'm creating buttons dynamically on an Excel userform with the following code:</p>
  
  <pre><code>With Me.CurrentFrame.Controls.Add("Forms.CommandButton.1")
      .Caption = "XYZ"
      .name = "AButton"
      .Font.Bold = True
      .ForeColor = &amp;HFF&amp;
      ... blah blah blah
  End With
  </code></pre>
  
  <p>I'd like to assign a function to run when these buttons are clicked, but I can't find a straightforward way to do this since there's no property as part of the button itself.</p>
  
  <p>Is there a way to do this using the above idiom? Should I be going about this whole thing in a different way?</p>