Dim Bookname As String
Dim OriginalBook As String
Dim TimeStamp As String
Dim NewBook As String
Dim x As Integer
OriginalBook = ActiveWorkbook.Name
TimeStamp = Now
Fileout = "FilterTurbidity" & DatePart("m", TimeStamp) & DatePart("d", TimeStamp) & DatePart("yyyy", TimeStamp)
OriginalBook = ActiveWorkbook.Name
Bookname = "\\wtpserver\hmi\Filter Reports Catalog\" & Fileout & ".xls" 'creates a unique filename based on the date
Workbooks.Add 'creates a temporary workbook to hold copied data
NewBook = ActiveWorkbook.Name
Workbooks(OriginalBook).Activate 'sets original workbook as the target
ActiveWorkbook.RefreshAll 'refreshes all sql queries
Cells.Copy 'copies all data
Workbooks(NewBook).Activate 'sets the temporary workbook as the target
Cells.PasteSpecial xlPasteColumnWidths 'copies column widths
Cells.PasteSpecial xlPasteValuesAndNumberFormats 'replaces with values only
Range("A1:O1").Select 'this section is for making static columns in bold font
Selection.Font.Bold = True
Range("A1:O1").Select
With Selection.Font
.Name = "Arial"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Application.CutCopyMode = False
ActiveWorkbook.Close True, Bookname 'closes both the new workbook and the original