Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Running a macro from the spreadsheet

I have built a macro in VB for a particular spreadsheet, opening VB from
within Excel. The macro is in the Forms folder and double clicking the
button (that starts the macro) on the form opens the code window.

I can now run the macro successfully within the VB window, using the Run
Sub/Userform button. How do I initiate this macro from the spreadsheet
ToolsMacroMacros window? It is not listed there currently.

I would like to email this macro to my partner to use. Does it have to be
emailed with the spreadsheet in which it was built? I would rather it were
possible to run it with any designated spreadsheet.

Thanking you in anticipation.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Running a macro from the spreadsheet

I macro that runs from a button is located on one of the VBA sheet windows.
code that runs from the Tool - Macro button are located in Modules. The
simpliest way to havve the code run from both envirnoments is to move the
code from the Sheet window to a module window. Add a new module to VBA and
copy the code from the sheet window to the modeule leaving the Sub statement
and End Sub statement. the add a call stement from the sheet macro to the
module macro


sheet window
Sub commandbutton_click()
call Commoncode()
end sub

module window
Sub Commoncode()
'insert the code that was originally in the sheet window
end sub

"Roger Withnell" wrote:

I have built a macro in VB for a particular spreadsheet, opening VB from
within Excel. The macro is in the Forms folder and double clicking the
button (that starts the macro) on the form opens the code window.

I can now run the macro successfully within the VB window, using the Run
Sub/Userform button. How do I initiate this macro from the spreadsheet
ToolsMacroMacros window? It is not listed there currently.

I would like to email this macro to my partner to use. Does it have to be
emailed with the spreadsheet in which it was built? I would rather it were
possible to run it with any designated spreadsheet.

Thanking you in anticipation.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Running a macro from the spreadsheet

Thanks. Worked a treat.

The macro is associated with a specific spreadsheet. Is it possible to save
the macro in a separate file so that it can be used with any designated
spreadsheet.

Thanking you in anticipation.

"papou" wrote:

Hi Roger

Create a Sub in a standard module and then call your form from this sub.
eg:
Sub LaunchMyForm()
Load USerForm1
UserForm1.Show
End Sub

HTH
Cordially
Pascal

"Roger Withnell" a écrit dans le
message de news: ...
I have built a macro in VB for a particular spreadsheet, opening VB from
within Excel. The macro is in the Forms folder and double clicking the
button (that starts the macro) on the form opens the code window.

I can now run the macro successfully within the VB window, using the Run
Sub/Userform button. How do I initiate this macro from the spreadsheet
ToolsMacroMacros window? It is not listed there currently.

I would like to email this macro to my partner to use. Does it have to be
emailed with the spreadsheet in which it was built? I would rather it
were
possible to run it with any designated spreadsheet.

Thanking you in anticipation.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Running a macro from the spreadsheet

You could put the macro into your personal.xls file. Do a search on your C:
dirve for the directory XLSTART (varies with different versions of offfice)
and create an Excel file called personal.xls. Add macro to this workbook.
then everytime you open excel this macro can be called.

"Roger Withnell" wrote:

Thanks. Worked a treat.

The macro is associated with a specific spreadsheet. Is it possible to save
the macro in a separate file so that it can be used with any designated
spreadsheet.

Thanking you in anticipation.

"papou" wrote:

Hi Roger

Create a Sub in a standard module and then call your form from this sub.
eg:
Sub LaunchMyForm()
Load USerForm1
UserForm1.Show
End Sub

HTH
Cordially
Pascal

"Roger Withnell" a écrit dans le
message de news: ...
I have built a macro in VB for a particular spreadsheet, opening VB from
within Excel. The macro is in the Forms folder and double clicking the
button (that starts the macro) on the form opens the code window.

I can now run the macro successfully within the VB window, using the Run
Sub/Userform button. How do I initiate this macro from the spreadsheet
ToolsMacroMacros window? It is not listed there currently.

I would like to email this macro to my partner to use. Does it have to be
emailed with the spreadsheet in which it was built? I would rather it
were
possible to run it with any designated spreadsheet.

Thanking you in anticipation.




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
Running a Macro from a Spreadsheet Function Patrick (GVC) Excel Worksheet Functions 2 February 10th 08 12:30 PM
Automatic running of Macro for the whole spreadsheet Rob Excel Programming 1 June 29th 05 08:19 PM
Prevent A Macro From Running If SpreadSheet is Filtered carl Excel Worksheet Functions 1 June 22nd 05 04:04 PM
Macro Running at Spreadsheet Start MWhitehead Excel Programming 3 June 10th 04 12:35 PM
Running Macro when value in spreadsheet is true pgerrish Excel Programming 0 April 22nd 04 05:32 PM


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

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

About Us

"It's about Microsoft Excel"