Macro to run automatically

Ed Namzug

New Member
Joined
Mar 21, 2002
Messages
9
How can a Macro run automatically as soon as the file is opened or 'clicked' on?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Well you can toss you're code into a Workbook_Open Event..


Private Sub workbook_open()
(yourcode here)
End Sub

To apply, open the VB editor, select "This Workbook" in you're Project Explorer and toss in your code with the sub name above.

HtH
 
Upvote 0
If it is a macro that you want to run on open have you tried declaring the:

Sub Auto_Open()
Your Macro Here
End Sub

This will run whenever the worksbook/sheet opens, however the user will be prompted if they want any macros to run.... if this is not the case give me a yell and I'll try and help where I can....
 
Upvote 0
Thanks Kevin, Am very grateful..!!
It worked..!!
Ed
On 2003-01-08 15:05, kevin.philips wrote:
If it is a macro that you want to run on open have you tried declaring the:

Sub Auto_Open()
Your Macro Here
End Sub

This will run whenever the worksbook/sheet opens, however the user will be prompted if they want any macros to run.... if this is not the case give me a yell and I'll try and help where I can....

[/quote]
 
Upvote 0

Forum statistics

Threads
1,215,779
Messages
6,126,846
Members
449,343
Latest member
DEWS2031

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