New button on toolbar

G

Guest

Can i create a new toolbar button which will format a cell in a particular
style?

I am trying to create a style similar to "Comma style" but without any
decimal places.
 
D

damorrison

attaboy said:
Can i create a new toolbar button which will format a cell in a particular
style?

I am trying to create a style similar to "Comma style" but without any
decimal places.


This is right from excel help file


Run a macro from a toolbar button
You can run a macro from a button on a built-in toolbar or a custom
toolbar. For information about creating a custom toolbar, click .

On the Tools menu, click Customize.
Show Me

If the toolbar that contains the button is not visible, click the
Toolbars tab, and then select the check box next to the toolbar name.


If the button you want to run the macro from is not on a toolbar, click
the Commands tab, and then click Macros in the Categories list. In the
Commands list, drag the Custom button onto a toolbar.


Right-click the toolbar button, and then click Assign Macro on the
shortcut menu.


In the Macro name box, enter the name of the macro.

-----------------------------------

use a macro like this

All I did was record the macro

Sub Format()
'
'
'

'
Selection.NumberFormat = "###,###"
End Sub
 
G

Guest

Yes copy the following code into a module, this is the macro code that you
will need to reference when you create a custom macro button.

Sub comma0()
With Selected
Cells.NumberFormat = "0,000"
End With
End Sub

Hope this helps
 
G

Guest

Thnx
I created a macro in a file(say 1.xls) & linked it to a button, works OK in
1.xls; If 1.xls is closed and i try to apply the style in another file (say
2.xls), 1.xls opens up, how can this be avoided?

rgds
 
D

Dave Peterson

Lots of people store these kinds of macros in a workbook named Personal.xls in
their XLStart folder. They use windows|Hide so that the workbook is hidden
while it's open.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

New toolbar button 1
Currency, Percent and Comma Style buttons 1
Comma Style Question 3
comma style button 1
Modify Toolbar Button Styles 1
Comma Style 4
Format a number 3
Saving a custom number format 2

Top