I have the following code that exports a sheet to a CSV file.
If the file already exists, I want a warning to over-write or not.
If the user doesn’t want to over-write, I need to exit the VB application.
What’s missing?
Sub ExportCSVFINAL() Dim wbkExport As Workbook Dim shtToExport As Worksheet Worksheets("TextFile").Activate FName = Cells(1, 15).Value Set shtToExport = ThisWorkbook.Worksheets("MarrReformatted") 'Sheet to export as CSV Set wbkExport = Application.Workbooks.Add shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count) Application.DisplayAlerts = False wbkExport.SaveAs FileName:=FName, FileFormat:=xlCSV wbkExport.Close SaveChanges:=True End Sub