Hoping someone can help
Im not sure if its because of the array the sheets are in
Any help appreciated
Private Sub CommandButton1_Click()
Application.EnableEvents = False
Dim iRet As Integer
Dim strPrompt As String
Dim strTitle As String
' Promt
strPrompt = "Have you saved any Changes?"
' Dialog's Title
strTitle = "Warning Changes won't be Saved"
'Display MessageBox
iRet = MsgBox(strPrompt, vbYesNo, strTitle)
' Check pressed button
If iRet = vbNo Then
ThisWorkbook.Save
Else
If iRet = vbYes Then
Dim MyArray As Variant
Dim i As Long
MyArray = Array("December", "Totals")
Sheets(MyArray).Select
For i = LBound(MyArray) To UBound(MyArray)
With Worksheets(MyArray(i))
.Unprotect
End With
Next i
ActiveWindow.FreezePanes = False
ActiveWindow.View = xlPageLayoutView
End If
Dim DataWorkbook As Workbook
Dim SaveFileName As String
Set DataWorkbook = ActiveWorkbook
DataWorkbook.Sheets(Array("December", "Totals")).Copy
With ActiveSheet
.UsedRange = .UsedRange.Value
End With
SaveFileName = "\\Generated Reports\" & Format(Now, "yyyymmdd") & "Report.xlsx"
ActiveWorkbook.SaveAs Filename:=SaveFileName
MsgBox "New Report Created and Saved As" & SaveFileName
ActiveWorkbook.Close
ThisWorkbook.Close False
End If
End Sub
Bookmarks