Adding Custom Macros to an Excel Toolbar
Before adding these custom buttons, you should
create your own personal add-in. Don't worry, this is a piece of cake.
- Open up a new workbook.
- Start up VBA. (Press Alt+F11)
- Insert a new module. (Insert > Module)
- Copy and paste the VBA code into the module.
- (Take note of what the macro is called).
- Get out of VBA. (Press Alt+Q)
- Save your workbook as an addin (.xla) file, calling it something like My_Addin.xla
- Exit out of Excel, then start it up again.
- Enable your new addin (Go to Tools > Add-Ins and select your new addin).
Creating a new macro button in a toolbar.
- Go to Tools > Customize
- In the Commands tab, click on the Macros category.
- Copy (drag and drop) the Custom Button to one of your toolbars.
- Right-click on the button and select Default Style to display only the image.
- Copy and paste the button image as described above.
- Right-click on the button and select Assign Macro ...
- Type the exact name of the macro and select OK
Word Wrap Toolbar Button
Image | Command Description |
| Toggle word wrap within a selected cell or range of cells. |
Sub WordWrapBtn()
' Word Wrap Button Macro
Dim btnstate As Boolean
btnstate = Selection.WrapText
With Selection
If btnstate Then
.WrapText = False
Else
.WrapText = True
End If
End With
End Sub