Hi,
I have the following sub (see below). This sub saves 3 worksheets as 3 seperate Excel files. During the procedure I get the following question with the options 'Yes' and 'No':
Do you want to save changes before switching file status?
I want to automate this procedure so that I don't have to choose 'Yes' manually anymore.
Thanks!
I have the following sub (see below). This sub saves 3 worksheets as 3 seperate Excel files. During the procedure I get the following question with the options 'Yes' and 'No':
Do you want to save changes before switching file status?
I want to automate this procedure so that I don't have to choose 'Yes' manually anymore.
Thanks!
Code:
Sub MaakKopie()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "yyyymmdd")
Application.EnableEvents = False
Application.ScreenUpdating = False
ThisWorkbook.Sheets(Array(2, 3)).Copy
Set wb = ActiveWorkbook
wb.SaveAs Filename:="c:\" & strdate & " MKB - Retail Performance Indicators.xls"
For x = 1 To wb.Sheets.Count
wb.Sheets(x).Range("A1:DZ1000").Copy
wb.Sheets(x).Range("A1:DZ1000").PasteSpecial xlPasteValues, , False, False
Next x
wb.Sheets(1).Range("A1:A1").Copy
wb.Sheets(1).Range("A1:A1").PasteSpecial xlPasteValues, , False, False
wb.ChangeFileAccess xlReadOnly
wb.Close
'2
ThisWorkbook.Sheets(Array(4)).Copy
Set wb = ActiveWorkbook
wb.SaveAs Filename:="c:\" & strdate & " MKB - Thermometer Rapportage.xls"
For x = 1 To wb.Sheets.Count
wb.Sheets(x).Range("A1:DZ1000").Copy
wb.Sheets(x).Range("A1:DZ1000").PasteSpecial xlPasteValues, , False, False
Next x
wb.Sheets(1).Range("A1:A1").Copy
wb.Sheets(1).Range("A1:A1").PasteSpecial xlPasteValues, , False, False
wb.ChangeFileAccess xlReadOnly
wb.Close
'3
ThisWorkbook.Sheets(Array(5, 6, 7, 8)).Copy
Set wb = ActiveWorkbook
wb.SaveAs Filename:="c:\" & strdate & " MKB - Continuon Performance Indicators.xls"
For x = 1 To wb.Sheets.Count
wb.Sheets(x).Range("A1:DZ1000").Copy
wb.Sheets(x).Range("A1:DZ1000").PasteSpecial xlPasteValues, , False, False
Next x
wb.Sheets(1).Range("A1:A1").Copy
wb.Sheets(1).Range("A1:A1").PasteSpecial xlPasteValues, , False, False
wb.ChangeFileAccess xlReadOnly
wb.Close
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub