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

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
980
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Hi Kipster,

Maybe this will help
Code:
Private Sub CommandButton1_Click()
    Call Macro_OpenFile
    CommandButton1.Enabled = False  'or CommandButton1.Visible = False
End Sub
 

Kipster1203

New Member
Joined
May 14, 2010
Messages
15
What does this do exactly?

I don't want to hide the button, I want to get rid of it altogether...
 

SaladProblems

Active Member
Joined
Apr 9, 2010
Messages
279
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.
 

Kipster1203

New Member
Joined
May 14, 2010
Messages
15
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.
 

ljungren13

Board Regular
Joined
Jun 4, 2010
Messages
195
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
 

aysam

Board Regular
Joined
Jun 24, 2009
Messages
217
I need the code to be run when the workbook is opened
use this
Code:
Sub auto_open()
'YOUR CODE HERE
End Sub
 

SaladProblems

Active Member
Joined
Apr 9, 2010
Messages
279
Also, if it helps, you can just do:

Private Sub Workbook_Open()
Call YourMacroName
End Sub
 
Last edited:

Kipster1203

New Member
Joined
May 14, 2010
Messages
15
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:

Forum statistics

Threads
1,176,716
Messages
5,904,606
Members
435,101
Latest member
oldmaninla

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
Top