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?
 

Some videos you may like

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Sahak

Well-known Member
Joined
Nov 10, 2006
Messages
864
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

ADVERTISEMENT

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
213

ADVERTISEMENT

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:

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,156
Messages
5,509,485
Members
408,737
Latest member
FortCeara2

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top