The problem in question centers around one workbook which contains all of my data and breakdowns spread across a ton of worksheets. I’m trying to get macros set up to copy select sheets to a new workbook. I think my biggest problem is getting the coding right for the destination workbook since the name includes a date string that changes each day. The code that I’ve got so far to just create the new workbook and close it is:
Sub NewReport()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
MyDate = Date
Dim dateStr As String
dateStr = Format(MyDate, "MM-DD-YY")
Set W = Application.Workbooks.Add
W.SaveAs Filename:="N:\PAR\" & "New Report Name" & " " & dateStr, FileFormat:=51
Application.ScreenUpdating = True
Application.DisplayAlerts = True
ActiveWorkbook.Close True
End Sub
This works and does what I want in regards to creating the new document, naming it the way it should be named, and at the end closing it. What I need help with is that middle portion for copying specific sheets from the original workbook to this new one. What I was thinking was along the lines of:
With Workbooks("Original Workbook.xlsm")
.Sheets(Array("Sheet1", "Sheet2")).Copy_ Before:=Workbooks("destination.xls").Sheet1
Or at least some type of array to get exactly what I want to copy over. The biggest sticking point is getting the destination workbook path name correct. Any advice regarding individual pieces of this little project or on the whole is greatly appreciated. Thanks!
EDIT: I also need to point out that the new workbook being generated needs to be just plain old excel format (.xlsx). No macros, no security warning for automatic updating links or enabling macros, zip. Just a plain book of the sheets I tell it to put there.
Ok. I finally got it working now. Sheet names are carried over (otherwise I would have to go behind and rename them); it saves one copy to be sent and one copy to our archive folder; and the new workbooks don’t get any popup about enabling macros or updating links. The code I finally settled on (which could probably be trimmed a little) is:
Hope that’ll help someone else with the same issue!