Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jo Jo is offline
external usenet poster
 
Posts: 113
Default Marcos and buttons

How do I write a macro that can be used in all workbooks and can I assign it
to a button?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Marcos and buttons

Below shows the typical, basic procedure to create a macro and assign it to a
button.

1) From the Tools menu, choose VBA Editor.
2) In the Project Explorer, locate a file you're working on, right-click the
VBAProject of that workbook, choose insert, then choose module.
3) In the new blank screen of the module which appeared, type a macro. e.g.

Sub hello()
Msgbox "hello world!"
End Sub

4) Close the window of the VBA Editor (go back to the spreadsheet)
5) From the View menu, choose Toolbars, then choose Forms.
6) Click the icon which represents a "Button" control. Place a button on the
worksheet.
7) You'll be asked to assign a macro to the button. Choose the macro you
just created. Click OK to finish.

If you want to learn more about this, I would recommend reading a book (e.g.
a "Step-by-Step" book from Microsoft Press on the Excel VBA topic.


Regards,
Edwin Tam

http://www.vonixx.com



"Jo" wrote:

How do I write a macro that can be used in all workbooks and can I assign it
to a button?

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jo Jo is offline
external usenet poster
 
Posts: 113
Default Marcos and buttons

Edwin

That is great but I actually wanted a customised button in the toolbar that
I could use in all excel spreadsheets

"Edwin Tam" wrote:

Below shows the typical, basic procedure to create a macro and assign it to a
button.

1) From the Tools menu, choose VBA Editor.
2) In the Project Explorer, locate a file you're working on, right-click the
VBAProject of that workbook, choose insert, then choose module.
3) In the new blank screen of the module which appeared, type a macro. e.g.

Sub hello()
Msgbox "hello world!"
End Sub

4) Close the window of the VBA Editor (go back to the spreadsheet)
5) From the View menu, choose Toolbars, then choose Forms.
6) Click the icon which represents a "Button" control. Place a button on the
worksheet.
7) You'll be asked to assign a macro to the button. Choose the macro you
just created. Click OK to finish.

If you want to learn more about this, I would recommend reading a book (e.g.
a "Step-by-Step" book from Microsoft Press on the Excel VBA topic.


Regards,
Edwin Tam

http://www.vonixx.com



"Jo" wrote:

How do I write a macro that can be used in all workbooks and can I assign it
to a button?

  #4   Report Post  
Posted to microsoft.public.excel.programming
Jo Jo is offline
external usenet poster
 
Posts: 113
Default Marcos and buttons

It's OK, I just figured it out.

Thansk

"Jo" wrote:

How do I write a macro that can be used in all workbooks and can I assign it
to a button?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Marcos and buttons

How did you solve this?
I have posted my question but, not getting a response.
I have a template toolbar macro which renames the spreadsheet using the
value of cell a12. My macro is called 'SaveToFolder'.
IF I type 'BJS1' into cell a12 and click the macro, I have BJS1.xls saved to
my hard drive. If I look at the macro to see what it's assigned to it says
'BJS1.xls', not 'SaveToFolder'.

Any idea?

"Jo" wrote:

It's OK, I just figured it out.

Thansk

"Jo" wrote:

How do I write a macro that can be used in all workbooks and can I assign it
to a button?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help on Marcos abc[_2_] Excel Discussion (Misc queries) 0 May 25th 10 08:14 AM
Delete old Marcos cyndi Excel Discussion (Misc queries) 1 October 24th 07 10:08 PM
Marcos cjloneranger Excel Worksheet Functions 1 August 9th 05 03:39 PM
Excel Marcos Mark Allen[_2_] Excel Programming 1 July 15th 04 05:39 AM
Printing Marcos Keri[_2_] Excel Programming 2 April 23rd 04 07:44 PM


All times are GMT +1. The time now is 02:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"