With the use of buttons, we are able to create a user-friendly interface for the use of macros.
There are two types of elements that can be inserted from the Insert button in the Developer tab:
For now we will use the Form Controls, which are simpler.
To rename a button, right-click it and select Edit Text.
You can also associate a shape with a macro:
If you do not have a macro recorded at the time you inserted the button (or shape), you can record one and assign it to the button later.
To assign a macro to a button (or a shape) just right-click it, and select "Assign Macro...".
For learning purposes, create with the macro recorder a simple macro that changes the color of the text to green. Assign this macro to the button we previously inserted into the worksheet.
Remember to use relative references.
In this example, we startedand then we added a color to the text by clicking Home $\rightarrow$ Font $\rightarrow$ Font Color ().
Macro assigned to the Button:
Sub Macro1() ' ' Macro1 Macro ' ' With Selection.Font .Color = -12597620 .TintAndShade = 0 End With End Sub
Now just select one or more cells with text, click the button and the color of the text will turn green.
SuperExcelVBA.com is learning website. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. All Rights Reserved.
Excel ® is a registered trademark of the Microsoft Corporation.
© 2019 SuperExcelVBA | ABOUT