I have a code that currently works, however it does not complete my task. Okay I have variables on Sheet5 "codes" (I prefer the code names to the sheet names... just in case someone renames them).
sheet5 variables:
C15 - Concatenation of new filename desired (c22 & I18)
C22 - "base" file name
I18 - date added to filename (added in format of mm.dd.yy)
There are a total of 6 sheets in my template (where the macros are). The ones being copied are Sheet1, Sheet3, Sheet4, Sheet5. The desire is to copy those 4 sheets to a new workbook, name the file using the base name and the date, save as an xlsx (no macros) to the same directory that the template is located. I also want to have sheet1 and sheet5 hidden. Leave the NEW file open, save and close the template.
Currently, the macro copies those 4 sheets to a new workbook, however I cannot get the template files to save and close, or the new file to hide those 2 sheets. I am close.
![]()
Sub SaveSomeSheets() Dim FName As String Dim Path As String ' Optimize Macro Speed Application.ScreenUpdating = False Application.DisplayStatusBar = False Application.EnableEvents = False Application.DisplayAlerts = False ' Sheet name and cell listing file name FName = Sheet5.Range("$C$22") & " " & Format(Sheet5.Range("$I$18"), "mm.dd.yy") & ".xlsx" Path = ActiveWorkbook.Path & "\" & FName Sheets(Array(Sheet1.Name, Sheet3.Name, Sheet4.Name, Sheet5.Name)).Copy ActiveWorkbook.SaveAs Filename:=Path, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False ' ActiveWindow.Close ResetSettings: ' Reset Macro Optimization Settings Application.DisplayAlerts = True Application.EnableEvents = True Application.DisplayStatusBar = True Application.ScreenUpdating = True End Sub











LinkBack URL
About LinkBacks
Register To Reply


Bookmarks