auto run macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Guest
Is there a way to automatically run a macro any time a workbook is opened?
Thanks,
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
sure put the code in thisworkbook code replace msgbox with your code

Sub auto_open()
MsgBox "your text here"
'put in module will display a msg box with your text
'when workbook is opened
End Sub
 
Upvote 0
Enter into ThisWorkbook in the VB Editor for the workbook you want the code to run.

Private Sub Workbook_Open()

' your code here or reference to your macro.
End Sub
 
Upvote 0
On 2002-03-03 21:42, gplhl wrote:
Enter into ThisWorkbook in the VB Editor for the workbook you want the code to run.

Private Sub Workbook_Open()

' your code here or reference to your macro.
End Sub
a little sub-question about this problem.
Is it possible that when the workbook is open the screen will automatic change in a specific color?
Thanks.
 
Upvote 0
For example : change the color to yellow

<pre>
Private Sub Workbook_Open()
Cells.Select
With Selection.Interior
.ColorIndex = 6 '(colorindex 6 = yellow)
.Pattern = xlSolid
End With
Range("A1").Select
End Sub

</pre>
 
Upvote 0

Forum statistics

Threads
1,223,365
Messages
6,171,656
Members
452,415
Latest member
mansoorali

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