Create an icon

  • Thread starter Thread starter Aruna
  • Start date Start date
A

Aruna

How to create an icon on my toolbar, clicking on which, will perform some
defined tasks?

Example of my expected result: Clicking on that icon once, make the selected
cell into bold, italics, underlined and centered.
 
A good question!

First create a macro to do the formatting and then:

View > Toolbars > Customize... (way at the bottom of the drop-down)

Commands > Macros > and drag the custom buttton onto the toolbar.

Finally assign the macro to the new button.
 
And how to create a macro please

Gary''s Student said:
A good question!

First create a macro to do the formatting and then:

View > Toolbars > Customize... (way at the bottom of the drop-down)

Commands > Macros > and drag the custom buttton onto the toolbar.

Finally assign the macro to the new button.
 
Here is the macro you require:

Sub Formatt()
Dim r As Range
For Each r In Selection
r.HorizontalAlignment = xlCenter
r.Font.FontStyle = "Bold Italic"
r.Font.Underline = xlUnderlineStyleSingle
Next
End Sub

Macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To use the macro from the normal Excel window:

1. ALT-F8
2. Select the macro
3. Touch Run



To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To learn more about macros in general, see:

http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
Back
Top