Changing file name in recorded macro

%3CLINGO-SUB%20id%3D%22lingo-sub-2458468%22%20slang%3D%22en-US%22%3EChanging%20file%20name%20in%20recorded%20macro%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2458468%22%20slang%3D%22en-US%22%3E%3CP%3EI%20recorded%20the%20following%20code%20to%20copy%20a%20worksheet%20that%20will%20be%20the%20new%20standard%20layout%20into%20an%20existing%20file.%20The%20item%20I%20have%20in%20bold%20is%20the%20file%20name%20that%20will%20change%20each%20time.%26nbsp%3B%26nbsp%3B%3CEM%3EThanks%20in%20advance!%3C%2FEM%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20CopyWorksheet()%3CBR%20%2F%3E'%3CBR%20%2F%3E'%20CopyWorsheet%20Macro%3CBR%20%2F%3E'%3CBR%20%2F%3E'%20Keyboard%20Shortcut%3A%20Ctrl%2BShift%2BW%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ESheets(%22Sheet1%22).Select%3CBR%20%2F%3ESheets(%22Sheet1%22).Copy%20Before%3A%3DWorkbooks%3CSTRONG%3E(%225011%20CHS%20REV%20B.xlsx%22)%3C%2FSTRONG%3E.Sheets(1)%3CBR%20%2F%3ESheets(%22Sheet1%20(2)%22).Select%3CBR%20%2F%3EWindows(%222021%20MASTER%20SPRINGING%20SPEC.xlsx%22).Activate%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2458468%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Visitor

I recorded the following code to copy a worksheet that will be the new standard layout into an existing file. The item I have in bold is the file name that will change each time.  Thanks in advance!

 

Sub CopyWorksheet()
'
' CopyWorsheet Macro
'
' Keyboard Shortcut: Ctrl+Shift+W


Sheets("Sheet1").Select
Sheets("Sheet1").Copy Before:=Workbooks("5011 CHS REV B.xlsx").Sheets(1)
Sheets("Sheet1 (2)").Select
Windows("2021 MASTER SPRINGING SPEC.xlsx").Activate
End Sub

0 Replies