Hi All,
I have the following code
The code stops working on this line:
Can anyone spot a bug?
Thanks
I have the following code
Code:
Sub Automatization()
Dim twb As Workbook, wb As Workbook, new_sheet_counter As Integer
Application.ScreenUpdating = False
Set twb = ThisWorkbook
new_sheet_counter = Application.SheetsInNewWorkbook
Set wb = Workbooks.Add
'----- Copy relevant worksheets to new book -----
twb.Sheets(Array("DashboardTotal", "DashboardMT", "DashboardPT")).Copy After:=wb.Sheets(new_sheet_counter)
'----- Remove original worksheets and set others to values-only -----
Application.DisplayAlerts = False
With wb
For counter = 1 To new_sheet_counter
.Sheets("Sheet" & counter).Delete
Next
For Each ws In wb.Worksheets
ws.Cells.Copy
ws.Cells.PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
Next
wb.Sheets("DashboardTotal").Select
End With
'----- Set up variables for saving report -----
reportingdate = Format(Date, "dd-mmm-yyyy")
reportingtime = Format(Time, "hh-mm")
outputlocation = coding.Range("b1")
If Right(outputlocation, 1) <> "\" Then outputlocation = outputlocation & "\"
vsion = 1
'----- Save new workbook with version control -----
wb.SaveAs Filename:=outputlocation & "Daily Report-" & reportingdate & "-" & reportingtime & ".xlsx"
wb.Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
The code stops working on this line:
Code:
wb.SaveAs Filename:=outputlocation & "Daily Report-" & reportingdate & "-" & reportingtime & ".xlsx"
Can anyone spot a bug?
Thanks