title: Create CSV in VBA for Excel for certain range with prompt if file exists
body: <p>I've mixed code and get good results considering that I wish to create csv file without header and for first 12 columns of file.</p>
  
  <p>Also, I've found way to send message about successful creation. My main problem now, is the fact that I can't push code to ask me if file exists, and to create it just after confirmation.</p>
  
  <p>The best solution will be if I may on easier way do next:</p>
  
  <ul>
  <li>create csv for range defined in code</li>
  <li>confirm if I wish to overwrite existing file</li>
  <li>open file in notepad</li>
  </ul>
  
  <p>Below is code and obviously I need help </p>
  
  <pre><code>Private Sub CommandButton1_Click()
  Dim fs As Object, a As Object, i As Integer, s As String, t As String, l As String, mn As String, PathCSV As String, NameCSV As String
  
      PathCSV = "D:\BOM\"
      NameCSV = "MMA - " &amp; Format(Date, "mmmm yyyy") &amp; ".csv"
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set a = fs.CreateTextFile("D:\BOM\MMA - " &amp; Format(Date, "mmmm yyyy") &amp; ".csv", True)
  
      For r = 5 To Range("A65536").End(xlUp).Row 'start in row 5  due row 1-4 is header
          s = ""
          c = 1
          While c &lt; 13
              s = s &amp; Cells(r, c) &amp; ","
              c = c + 1
          Wend
          a.writeline s 'write line
      Next r
      MsgBox "CSV file successfully save to " &amp; PathCSV &amp; NameCSV
  End Sub
  </code></pre>