hi
i DO want to overwrite existing file when i export new file
what do i need to change in my code to check if file exists, kill it and save new file?
i DO want to overwrite existing file when i export new file
what do i need to change in my code to check if file exists, kill it and save new file?
Rich (BB code):
Sub ExportCurrentBilling()
Dim wb As New Workbook
Dim SaveFolder As String: SaveFolder = "M:\all\FI Payments\Billing Services 10_11_13_14_15_16\CURRENT\"
Dim FileName As String
Dim tbl As ListObject
With ActiveWorkbook.Worksheets("Billing")
FileName = "Current"
Set tbl = .ListObjects(1)
tbl.Range.Copy
End With
Set wb = Workbooks.Add
wb.Activate
wb.Sheets(1).Range("A1").PasteSpecial xlPasteAll
Selection.Columns.AutoFit
FullFileName = FileName & ".xlsx"
'Save and Close New WB
wb.SaveAs SaveFolder & "\" & FullFileName, xlOpenXMLWorkbook
wb.Close SaveChanges:=False
'Back to Main WB
ThisWorkbook.Activate
'Inform User
MsgBox "File Export Complete", vbInformation
End Sub