title: Excel VBA Exporting specific columns to CSV
body: <p>I'm fairly new to VBA programming, but still managed to make a small code which exports an Excel sheet to a CSV file. This must be as user friendly as possible, so I came up with this:</p>
  
  <pre><code>Sub export_first()
  
      Application.DisplayAlerts = False
  
      Dim wb As Workbook, InitFileName As String, fileSaveName As String
  
      InitFileName = ThisWorkbook.Path &amp; "\Export nr1_" &amp; Format(Date, "yyyymmdd")
  
      Sheets("MySheetNameToExport").Copy
  
      Set wb = ActiveWorkbook
  
      fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitFileName, _
      fileFilter:="Semicolon separated CSV (*.csv), *.csv")
  
      With wb
          If fileSaveName &lt;&gt; "False" Then
  
              .SaveAs fileSaveName, FileFormat:=xlCSV, Local:=True
              .Close
          Else
              .Close False
              Exit Sub
          End If
      End With
  
  End Sub
  </code></pre>
  
  <p>This works just fine. It is added to a button, and when the button is pressed, the codes does all the job. Now the thing is, my coworkers came up with an idea, that we should use columns that checks some values for the users (lets call them C, D) but when they export the worksheet, these columns must be ignored and not exported. What I tried to do is to extend the Sheets line like:</p>
  
  <pre><code>Sheets("MySheetNameToExport").Range("A:B, E:G").Copy
  </code></pre>
  
  <p>But when I add this modified line to my macro and run the code, Excel crashes and exports the very first sheet which is just some welcome text and is totally unnecessary. </p>