This is a simple guide to create and assign a “button” to your simple VBA code.
Credit to WiseOwlTutorials. You can check him on Youtube
- Let’s create a simple VBA code in a module
- A simple code like this will do for our example
-
Sub NameIsNanaKofi() Worksheets.Add Range("A1").Value = "My Name is Nana Kofi"End Sub
- Now let’s create an object
- Click on the Developer Ribbon in Excel
- Click on the INSERT button and choose the button you like
- Draw the button and you can rename it to any name you want and you can also resize it.
- Now let’s assign our macro, the one we created here : Simple Basic VBA code to our button
- Right click on the “button” and select “Assign Macro”
- Click OK and click outside the button
- Now click on your button to see your VBA code executed.
Please let me know if you have any remarks , by leaving it in the comment box below.