VBA Saving single sheet as CSV (not whole workbook)

后端 未结 3 482
悲&欢浪女
悲&欢浪女 2020-12-10 11:02

I appreciate there are lots of entries like save individual excel sheets as csv and Export each sheet to a separate csv file - But I want to save a single worksheet<

3条回答
  •  再見小時候
    2020-12-10 11:49

    This code works fine for me.

    Sub test()
    
    Application.DisplayAlerts = False
    
    ThisWorkbook.Sheets(strSourceSheet).Copy
    ActiveWorkbook.SaveAs Filename:=strFullname, FileFormat:=xlCSV, CreateBackup:=True
    ActiveWorkbook.Close
    
    Application.DisplayAlerts = True
    
    End Sub
    

    It's making a copy of the entire strSourceSheet sheet, which opens a new workbook, which we can then save as a .csv file, then it closes the newly saved .csv file, not messing up file name on your original file.

提交回复
热议问题