title: Export all but certain excel sheets to CSV via VBA?
body: <p>Based on some other stuff I found here, I have made the following script to do almost exactly what I want.  It will export all but 4 specific sheets in an excel file to CSV files, append dates to them, and save them to dated folders.  The only problem is it renames the sheets it exported in the original processing file.  How can I rectify this?</p>
  
  <pre><code>Sub SaveLCPWorksheetsAsCsv()
  
  Dim WS As Excel.Worksheet
  Dim SaveToDirectory As String
  
  Dim CurrentWorkbook As String
  Dim CurrentFormat As Long
  
  CurrentWorkbook = ThisWorkbook.FullName
  CurrentFormat = ThisWorkbook.FileFormat
  ' Store current details for the workbook
  
    SaveToDirectory = "C:\test\" &amp; Format(Date - 1, "YYYYMM") &amp; "\"
  
    If Len(Dir(SaveToDirectory, vbDirectory)) = 0 Then
      MkDir SaveToDirectory
    End If
  
    For Each WS In ThisWorkbook.Worksheets
      If WS.Name &lt;&gt; "Input" And WS.Name &lt;&gt; "Ref" And WS.Name &lt;&gt; "Total" And WS.Name &lt;&gt; "Affected Accounts" Then
          WS.SaveAs SaveToDirectory &amp; WS.Name &amp; "_" &amp; Format(Date - 1, "YYYYMMDD"), xlCSV
      End If
    Next
  
   Application.DisplayAlerts = False
    ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
   Application.DisplayAlerts = True
  ' Temporarily turn alerts off to prevent the user being prompted
  '  about overwriting the original file.
  
  End Sub
  </code></pre>