Macro auto run when open

cassie123

New Member
Joined
May 27, 2015
Messages
21
Hi all,

I have a workbook that include at least 200 command button, I didnt want to click every single button to run the macro, is there any ways to get it run automatically when I open the file?

Thanks a lot
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hiya,

I'm no VBA expert, but I know this is possible and thought I'd try to steer you in a (hopefully right) direction, at least to get the discussion going.

To do this you need to open up the Visual Basic editor (Right click on any tab and select 'View Code').

In the left hand window that contains lists of the worksheets and modules, under 'Microsoft Excel Objects', should be 'This Workbook'. Double click on the and you should get a box open in the right with no code in. You can then insert code that triggers upon opening like this:

Code:
Private Sub Workbook_Open()
  
'your macro here'

End Sub

Depending on what sort of macros live under your buttons, you may be able to simply copy and paste your codes between these lines and have it work. More likely you'll need to string them together somehow, or have the sub 'call' the specified modules already in your sheet. There's a chance of course this could make your sheet very slow to open.

I hope this helps. I'm not likely to know exactly how to collect all the macros you wish to run in to one seamless code, but it's a start at least I hope!

Best regards

Sara
 
Upvote 0

Forum statistics

Threads
1,203,112
Messages
6,053,574
Members
444,674
Latest member
DWriter9

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