Create a Macro to remove Auto_Open before saving

AnnieLox

New Member
Joined
Sep 18, 2017
Messages
22
Hello! I have created an Auto_Open Macro with about 5 call macros within it. at the end it saves the file as todays date. I need the new file to no longer Auto_Open, however I still would like to have access to the macros.

Is there a way to delete only the Auto_Open Macro in the new file, or maybe change the name of the Auto_Open Macro so that it doesn't automatically run when opening the new file later?

thanks for y'alls help!
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I would recommend doing the following:
Adding an IF...THEN block in your Auto_Open code that only runs and calls the other macros when certain conditions are met. They you can just leave the code in there, and it will only run when you want it to (based on what you have told it).

You could use something like the file name to determine whether it should run or not. Or perhaps, have your other code update some random cell somewhere that indicates that the macros have already run, then have your IF...THEN block look at that. Whatever seems to make the most sense to you.
 
Upvote 0
Hi! thank you for that idea, it still took me a few days to think of a type of IF scenario to use.

is it possible to create a macro that would be if THIS file is named STP Backup- Auto Run then proceed, else end all?

my Auto run currently looks like this, so I would need the macro to not run any of the subs that are in the lineup. I would place the macro as the first CALL and if the file isn't named "stp..." then all of the codes stop. Am I making any since?

Code:
Sub All_In_One()
Call X_PreviousDay_Backup
Call X_NewData
Call age
Call uitbr
Call xfilterdata
Call AutoSort
Call SaveAs
End Sub
 
Upvote 0
It would look something like this:
Code:
Sub All_In_One()

    Dim myFileName As String
    
'   Get file name, minus extension
    myFileName = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1)
    
'   Only call macros if file name is "STP Backup- Auto Run"
    If myFileName = "STP Backup- Auto Run" Then
        Call X_PreviousDay_Backup
        Call X_NewData
        Call age
        Call uitbr
        Call xfilterdata
        Call AutoSort
        Call SaveAs
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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