canthony24
Board Regular
- Joined
- Mar 24, 2016
- Messages
- 70
How do I tell the VBA code to stop a particular action once it has been executed? I have my one of my macros copy an existing worksheet, then it hides it. But once I click the button to execute the macro again, it creates another copy of the worksheet. I only want it to create the copy of worksheet once, then hide it.
Basically, if the new copy is named "Source Data_Post", don't copy the original once the macro is executed again.
Ideas?
Here is the code I have for what I am asking about:
Sheets("Source Data").Select
Sheets("Source Data").Copy After:=Sheets(1)
Sheets("Source Data (2)").Select
Sheets("Source Data (2)").Name = "Source Data_Post"
Sheets("Source Data_Post").Select
ActiveWindow.SelectedSheets.Visible = False
Basically, if the new copy is named "Source Data_Post", don't copy the original once the macro is executed again.
Ideas?
Here is the code I have for what I am asking about:
Sheets("Source Data").Select
Sheets("Source Data").Copy After:=Sheets(1)
Sheets("Source Data (2)").Select
Sheets("Source Data (2)").Name = "Source Data_Post"
Sheets("Source Data_Post").Select
ActiveWindow.SelectedSheets.Visible = False