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?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi Kipster,

Maybe this will help
Code:
Private Sub CommandButton1_Click()
    Call Macro_OpenFile
    CommandButton1.Enabled = False  'or CommandButton1.Visible = False
End Sub
 
Upvote 0
Do you just want it to run when you open the workbook, or whenever you choose once it's already open?

Try hitting ALT+F8 if it's the latter, and that'll bring up a menu which lets you pick which macros to run.
 
Upvote 0
No I need the code to be run when the workbook is opened. It only needs to run once. This code updates a table of data.
 
Upvote 0
While in the VBE double click the Module called ThisWorkbook, seen in the Project Explorer (View>Project Explorer (Ctrl+R))

Private Sub Workbook_Open()

*CODE*

End Sub
 
Upvote 0
I need the code to be run when the workbook is opened
use this
Code:
Sub auto_open()
'YOUR CODE HERE
End Sub
 
Upvote 0
Also, if it helps, you can just do:

Private Sub Workbook_Open()
Call YourMacroName
End Sub
 
Last edited:
Upvote 0
I found ThisWorkbook but you lose me after that.... I pasted my code in there, but nothing happened. I'm assuming I'm missing something

I tried to put the auto open command in ThisWorkbook but got nothing
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,487
Messages
6,113,943
Members
448,534
Latest member
benefuexx

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