I have googled this and found multiple solutions for this but none of them have worked for me. I am inclined to believe this is because of my limited knowledge and ability when it comes to programming in VBA in Excel. If this is a repeat question of questions already posted here I apologize.
The question:
I have a code that executes on open of Excel Workbook. The code that executes saves the workbook as a new workbook under the name of a value located in a cell. I need the code that executes on open of Excel Workbook not to run on the new copy that has been created. The best way that I can think of to go about this would be to have a code that deletes part of or all of the code that executes on open of Excel Workbook. I have seen solutions for this before, I know that a solution exists but I do not know how to properly implement the code into my program so it works, I don't even know if the code I found will work which is why I have not provided it here. Here is the code that I have so far with comments explaining what I need in the code. Any help with this would be huge.
Thanks
Private Sub Workbook_Open()
'Saves filename as value of C10
Dim newFile As String, fName As String
fName = Range("C10").Value
newFile = fName & " " & Range("E9").Value
ChDir Range("A8")
ActiveWorkbook.SaveCopyAs Filename:=newFile
'Need code to delete a line of code or all code to prevent the code above from executing when the new Worksheet that has been created is opened.
ActiveWorkbook.Close False
End Sub
See Question&Answers more detail:os