Setting default module in VBA

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
913
Office Version
  1. 2016
Is there any way to set a default module in VBA? I have a workbook with two modules, one of them having code that I use next to never and one of them has code that I use several times a day. Everytime I open this workbook and press Alt+F11, the module I rarely use is opened (i.e. is the default module). How can I change this?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I am NOT sure, but I *think* it defaults to the last module created.
Can you verify this/test this and if it is true, you could delete the modules after exporting the code and import them again.
 
Upvote 0
What I normally do is just re-arrange the code in the Modules so the one I use most is in the last Module and therefore opens up when I press Alt+F11. Just insert a new Module and cut and paste the code in there and then delete the empty Module that is left.

BTW, this does not seem to work if you have say 10 or Modules because of the way they are sorted!

The other way of course is to add a button and run the Macro from there.

I hope this helps!
 
Upvote 0
What I normally do is just re-arrange the code in the Modules so the one I use most is in the last Module and therefore opens up when I press Alt+F11. Just insert a new Module and cut and paste the code in there and then delete the empty Module that is left.

I hope this helps!

Yeah, I thought this might be one solution and unless someone comes up with some "check the box in..." etc. answer, this is what I will do.

Thanks!
 
Upvote 0
You're welcome!

The other way of course is to add a button and run the Macro from there.

Thanks for the feedback.
 
Upvote 0
You're welcome!

The other way of course is to add a button and run the Macro from there.

Thanks for the feedback.

Or to make a shortcut key. The button is that kind of limited solution that (unless you mean a button in the ribbon), you have to go to some certain sheet to use it.
 
Upvote 0

Forum statistics

Threads
1,206,762
Messages
6,074,788
Members
446,088
Latest member
Koustubh12

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