

To create a MsgBox, add the following lines of code to the command button. The MsgBox is a dialog box in Excel that will prompt a message on your worksheet. Close the VBA editor and click on the command button on the worksheet.Add the following lines of code shown below.

Right-click on the command buttons and select View Code.To assign a macro to the command button, follow these steps: Drag the command button on your worksheet.Go the Developer tab > Insert > ActiveX Controls > Command button.To place a command button on your worksheet, follow these steps: Now that you have enabled the developer tab and have some familiarity with the VBA editor, let’s start creating a macro by using a command button. You can open the VBA interface by using the ALT + F11 keyboard shortcut, or you can go to the Developer tab and click on Visual Basic.Ĭreate an Excel Macro using a Command Button Create a Command Button Go to Customize the Ribbon and select the Developer checkbox.Right-click on the ribbon (anywhere) click on the Customize the Ribbon option.To customize the ribbon, follow the steps mentioned below: It hides the Developer tab on the ribbon by default.
