Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > Computer Information > Adding your own icon to the toolbar to run a macro in excel?

Reply
Thread Tools

Adding your own icon to the toolbar to run a macro in excel?

 
 
John
Guest
Posts: n/a
 
      12-15-2003
Hello.

I have a macro in excel which changes all the numbers in column a to
different numbers.

For example it turns the numbers 100 to 500 into 1000 to 5000.

This is an example of the macro.


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 14/12/2003 by John
'
' Keyboard Shortcut: Ctrl+k
'
Columns(1).Replace What:="100", Replacement:="1000",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Columns(1).Replace What:="200", Replacement:="2000",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Columns(1).Replace What:="300", Replacement:="3000",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Columns(1).Replace What:="400", Replacement:="4000",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
Columns(1).Replace What:="500", Replacement:="5000",
LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub


If I want to add my own icon to the toolbar in excel so that whenever
I click the icon it runs the macro, do you know how I can do this and
add it in?

Are the excel icons in the toolbar the same as the .ico files or are
they different?

Thanks very much for any help on how to do this.

John


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      12-15-2003
You can do:

tools|customize
(create a new toolbar on the Toolbars tab--or add to an existing toolbar).
Then on the commands tab, scroll down to macros in the category box.

drag the icon to your new toolbar
Then right click on that icon (with that dialog still open)
and you can assign it the macro you want, change the button image.

When you click on that icon, excel will find your workbook and open it (if it's
not already open) and run the macro.

===

Watch out for your macro. Do you really want xlpart (maybe xlwhole to limit it
more).

Someday, when you get lots of these macros, you may want to investigate John
Walkenbach's MenuMaker program.

This doesn't actually build a toolbar, but it adds an option to the worksheet
menubar. (I find this organization easier to use when there are lots of
macros.)

http://j-walk.com/ss/excel/tips/tip53.htm

John wrote:
>
> Hello.
>
> I have a macro in excel which changes all the numbers in column a to
> different numbers.
>
> For example it turns the numbers 100 to 500 into 1000 to 5000.
>
> This is an example of the macro.
>
> Sub Macro1()
> '
> ' Macro1 Macro
> ' Macro recorded 14/12/2003 by John
> '
> ' Keyboard Shortcut: Ctrl+k
> '
> Columns(1).Replace What:="100", Replacement:="1000",
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, MatchCase:=False
> Columns(1).Replace What:="200", Replacement:="2000",
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, MatchCase:=False
> Columns(1).Replace What:="300", Replacement:="3000",
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, MatchCase:=False
> Columns(1).Replace What:="400", Replacement:="4000",
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, MatchCase:=False
> Columns(1).Replace What:="500", Replacement:="5000",
> LookAt:=xlPart, _
> SearchOrder:=xlByRows, MatchCase:=False
> End Sub
>
> If I want to add my own icon to the toolbar in excel so that whenever
> I click the icon it runs the macro, do you know how I can do this and
> add it in?
>
> Are the excel icons in the toolbar the same as the .ico files or are
> they different?
>
> Thanks very much for any help on how to do this.
>
> John


--

Dave Peterson
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding print icon to compose toolbar dale.thomson@gmail.com Firefox 3 09-03-2007 04:02 PM
Your own photos in your own book Frank ess Digital Photography 1 12-09-2004 05:54 PM
My own handy Pocket Reference notes (please share your own also) David Filmer Perl Misc 17 08-18-2004 03:07 PM
Own your own cable modem. David Preece NZ Computing 19 01-09-2004 01:19 PM
Spam: Re: Own Your Own On-Line Travel Agency Howard NZ Computing 0 08-01-2003 07:46 AM



Advertisments