VBA Saving single sheet as CSV (not whole workbook)

后端 未结 3 487
悲&欢浪女
悲&欢浪女 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:51

    This is fairly generic

    Sub WriteCSVs()
    
    Dim mySheet As Worksheet
    Dim myPath As String
    
    'Application.DisplayAlerts = False
    
    For Each mySheet In ActiveWorkbook.Worksheets
    
        myPath = "\\myserver\myfolder\"
    
        ActiveWorkbook.Sheets(mySheet.Index).Copy
        ActiveWorkbook.SaveAs Filename:=myPath & mySheet.Name, FileFormat:=xlCSV, CreateBackup:=True
        ActiveWorkbook.Close
    
    Next mySheet
    
    'Application.DisplayAlerts = True
    
    End Sub
    

提交回复
热议问题