VBA question

cornbread

Board Regular
Joined
Apr 2, 2002
Messages
77
Is there any way to get excel to run a macro from a .bas file or project that isn't in any currently open workbook? I need to run a vba macro mutiple times without it updating where the button is assigned to the current workbook or sheet. Is there a way to do this? and or run the macro by referencing it's location outside of any open workbook?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
On 2002-04-12 06:22, cornbread wrote:
I need to run a vba macro mutiple times without it updating where the button is assigned to the current workbook or sheet.

I'm not quite sure what you're trying to say here. Could you clarify this for me?

The first part of your question about the .bas file and without looking into it too hard, I would say that this is not possible. I guess that this is sort of what .dll's are designed for. You'd need at least the full version of VB6 to create your own .dlls.

As for the second part, you can't call a macro from a closed workbook, it needs to be open. I think this is sort of common sense since there are some malicious macros out there.

HTH
 
Upvote 0
Basically I need to have a Macro permanently assigned to a button. I need that button to reference that Macro no matter what sheet is currently open. The only way I have found to do this so far is create that macro in a generic workbook have that workbook hide upon opening it and then open the workbooks I want to run the macro on. I would like a cleaner solution to this without stepping out into a VB project if I don't have to.
 
Upvote 0
I can code this, but I need to take some advice before posting here.

_________________<font color = green> Mark O'Brien
This message was edited by Mark O'Brien on 2002-04-12 07:19
 
Upvote 0
Right, that is esentially what I have and in the sub in book1 called main I have all my commands and it runs fine. However if you tie a button within excel to your run macro sub the button will update itself to reference the sheet last opened and saved in the path name to the macro. I suppose I could creat a VB form and have them open that first which would then run the sub much in the way you describe that way the button is not in Excel so it will quite updating itself. I will try that later today and post back if it doesn't work. Thanks for the help.
 
Upvote 0

Forum statistics

Threads
1,214,381
Messages
6,119,192
Members
448,874
Latest member
Lancelots

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