Loading .bas files and running macro

JoeS01

Well-known Member
Joined
Jun 25, 2005
Messages
832
I have a number of workbooks that I wish to run using the same macro stored in c:\temp\myMacro.bas

Is it possible with VBA code to insert a new macro , import the .bas file for the macro, and then run the macro for each of the workbooks?

I have tried recording this process, without any luck.

All suggestions greatly appreciated
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If you put the macro into your personal workbook, you can run it on any file (as long as it is working on "activeworkbook".
 
Upvote 0
Thanks for this quick response, tactps. I am not sure what you mean.
what is a personal workbook?

Can you please give me some more details on how to set it up?
Each of the workbooks I wish to run will be a single worksheet of data initially, and the macro adds additional worksheets containing the results
 
Upvote 0
From the Tools menu, choose "Macro", and "Record Macro".
In the drop-down list, choose "Personal Macro Workbook".
Click on OK, and then stop recording.

This will create a personal macro if you don't have any.

Press Alt-F11 to bring up VBA.
In the left pane, choose "VBA Project (Personal.xls)"
Then double-click on module1.

Import your macro.
Exit Excel.

When you next open Excel, the personal macro will be available.
 
Upvote 0
Excellent - many thanks for this tactps - works very nicley. Previously I was importing my macro to every file I needed processing, then running each sequentially. Keeping track of changes to the macro was a nightmare.

This way, I only need the one macro - goes like a train now :)
 
Upvote 0

Forum statistics

Threads
1,225,011
Messages
6,182,348
Members
453,107
Latest member
bb43442

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top