How can I tie a VBA macro to a button in Excel

前端 未结 1 686
暖寄归人
暖寄归人 2021-01-28 12:48

I have created a macro and a button but I can\'t see where to edit the button setting to invoke the macro. I\'m using Excel 2003.

相关标签:
1条回答
  • 2021-01-28 13:34

    If you've used a Form Control. The chance to assign a macro will come up right after you add the button to the sheet. Or, if the button is already on the sheet, you can right-click on it and select Assign Macro.

    If you've used an ActiveXControl, right-click on the button and select View Code. This will open up the VBE with

    Private Sub myCommandButtonName_Click() 
    
    End Sub
    

    From this sub call your macro like so...

    Private Sub myCommandButtonName_Click() 
    
    Call myMacro
    
    End Sub
    
    0 讨论(0)
提交回复
热议问题