In some of my previous post I wrote about how to use the SUB procedure. Now time to apply those SUB procedure into Button so that, you can run your macros by a single click.
How to add VBA button:
Before adding button, first create the simple SUB procedure as below:
Now a macro has added to your workbook named: addabutton. Click on Developer tab » Insert » Form Controls » Button.
Your mouse will convert to a '+' sign. Drag it on the spreadsheet and then release it. It will show Assign Macro dialog box like below:
Select the addabutton macro from Macro name list. Then Select This Workbook from Macros in drop down list. And then click on Ok.
To Rename the Button 1 Right Click on it, and select Edit Text. Then rename it as Top 30 Cells and click outside the button to exit from edit mode.
Now click on the Top 30 Cells button, and you will see the A1:E6 cells are populated with Test word.
How to add VBA button:
Before adding button, first create the simple SUB procedure as below:
Sub addabutton()
Range("A1:E6").Value = "Test"
End Sub
Now a macro has added to your workbook named: addabutton. Click on Developer tab » Insert » Form Controls » Button.
Image 1: Button (Form Controls)
Your mouse will convert to a '+' sign. Drag it on the spreadsheet and then release it. It will show Assign Macro dialog box like below:
Image 2: Assign Macro
Select the addabutton macro from Macro name list. Then Select This Workbook from Macros in drop down list. And then click on Ok.
Image 3: Assigned Button
To Rename the Button 1 Right Click on it, and select Edit Text. Then rename it as Top 30 Cells and click outside the button to exit from edit mode.
Image 4: Edit button name
Now click on the Top 30 Cells button, and you will see the A1:E6 cells are populated with Test word.
Image 5: Top 30 Cells button