Getting rid of a button

Kipster1203

New Member
Joined
May 14, 2010
Messages
15
This should be easy for some of you! I have a button that when clicked goes to a certain macro code. I need to get rid of the button so how do I get the code to run once when the file is opened?
 
Double click on ThisWorkbook and paste this:

Private Sub Workbook_Open()
Call YourMacroName
End Sub

Then change "YourMacroName" to what ever the macro is named that you already have assigned to the button
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi Kipster,

1. Copy
Private Sub Workbook_Open()
Call YourMacroName
End Sub

2. Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
3. Right-click on the ThisWorkbook object, and choose View Code
4. Paste
 
Last edited:
Upvote 0
Workbook_Open will happen if the workbook is opened manually or via code (from another workbook). It should be put in ThisWorkbook.


The Auto_Open will only run when the workbook is opened manually and should be put into a Standard Module.
 
Upvote 0
Im sorry,

1. Copy
Rich (BB code):
Private Sub Workbook_Open()
        Call YourMacroName
    End Sub
2. Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
3. Right-click on the ThisWorkbook object, and choose View Code
4. Paste
 
Upvote 0
read my post above about the difference between auto_open and workbook_open... the auto_open goes into a standard module

So paste:
Sub auto_open
call cell_color
End Sub

above "Sub Cell_Color()"

or leave what you have and change "auto" to "Workbook"
 
Upvote 0
I'm having a weird issue with this... This excel file can be opened from my Access program by clicking a report button. What you guys helped me with works fine when double clicking on the file itself (in the windows folder), however when opening the file using that Access button, the file opens but the auto open function doesn't work! I can't figure out why.... any ideas?
 
Upvote 0
I'm thinking about maybe using a worksheet or workbook event, so that the code is run when the worksheet or workbook is activated.... but haven't been able to get that to work yet.
 
Upvote 0

Forum statistics

Threads
1,215,689
Messages
6,126,215
Members
449,302
Latest member
rsizemore75

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