Try this (not tested).
Sub SaveAsValues()
'Save Monthly Report as Values in new workbook
Dim newWB As Excel.Workbook
Dim wks As Excel.Worksheet
Dim newWks As Excel.Worksheet
Dim vSheets As Variant
Dim varName As Variant
'----------------------------------------------
Application.DisplayAlerts = False
'Define the names of worksheets to be copied.
vSheets = VBA.Array("FTE Variance (8)", "Mill Levy Summary (7)", "Spending Graph (6)", _
"Forecasting Tool (5)", "16-17 Full Year (4)", "16-17 YTD (3)", _
"16-17 Current Month (2)", "Remaining Balance (1)", "Monthly Report Cover Page")
'Create referenece to the destination workbook.
Set newWkb = Excel.Workbooks.Add
newWkb.Connections.AddFromFile _
"C:\Users\PAUL_CYR\Documents\My Data Sources\fin-dmart-prod LAWSONDW GL SUMMARY CUBE.odc"
For Each varName In vSheets
'Clear reference to the [wks] variable.
Set wks = Nothing
'Check if there is a worksheet with such name
On Error Resume Next
Set wks = ThisWorkbook.Worksheets(VBA.CStr(varName))
On Error GoTo 0
'If worksheet with such neam is not found, those instructions are skipped.
If Not wks Is Nothing Then
'Copy this worksheet to a new workbook
wks.Copy After:=newWkb.Worksheets(1)
Application.CalculateUntilAsyncQueriesDone
'Get the reference to the copy of this worksheet and paste
'all its content as values
With newWkb.Worksheets(wks.Name)
.UsedRange.Value = .UsedRange.Value
End With
End If
Next varName
newWkb.SaveAs Filename:="H:\1_School Support\RBR FY17\Monthly Reports\October\" & Range("B1").Text & " - Monthly Report - October.xlsx"
Application.DisplayAlerts = True
End Sub
Bookmarks