title: How to create an ActiveX button and add code to it (tell it what sub to run) using vba?
body: <p>I'd like to create an ActiveX button in a sheet and assign a code to it (i.e. tell it to what sub to run and that sub already exists). </p>
  
  <p>I can create the button: (recorded)</p>
  
  <pre><code>ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
      , DisplayAsIcon:=False, Left:=41395.5882352941, Top:=234.705882352941, _
      Width:=119.117647058824, Height:=39.7058823529412).Select
  </code></pre>
  
  <p>But I'd like to change the caption and assign a sub to it so when someone clicks the newly created activex button it runs a sub that already lives in a module within the workbook that the button is to be created. Everything happens and lives in ThisWorkbook.</p>
  
  <p>Thanks!</p>
  
  <p>PS - I cannot use a Command button....I can only use ActiveX</p>