title: How to save excel file with incrementing number?
body: <p>I am looking for VBA to add to my macro that will increment the file name if the file name already exists.</p>
  
  <p>Current Code: </p>
  
  <pre><code>Dim filepath As String
  Dim filename As String
  Dim filepatharch As String
  Dim filedate As String
  Dim filelist As String
  
  'Grab FROM list number
  Sheets("TD File").Select
  Range("G4").Select
  filelist = ActiveCell.Value
  
  
  'Grab today's date
  filedate = Format(Now, "MMDD01.") --------------Currently where the '01' comes from (see below)
  
  'Set where to save and the file naming convention
  filepath = "\\home\serverfolder\FileDrop\"
  tdfilename = "TD" &amp; filedate &amp; filelist
  '&amp; ".txt"
  
  
  'Set where to save and the file naming convention
  filepatharch = "\\home\myfolder\archive"
  tdfilename = "TD" &amp; filedate &amp; filelist
  '&amp; ".txt"
  
  
  'Save THXXXXXX.XXX &amp; TDXXXXXX.XXX as flat files
     'Workbooks("MYWORK01").Activate
      Sheets("TDflatfile").Copy
      ActiveWorkbook.SaveAs filename:= _
          "\\home\serverfolder\FileDrop\" &amp; tdfilename, FileFormat:=xlCSV, _
          CreateBackup:=False
      ActiveWindow.Close
  </code></pre>
  
  <p>An example of the saved file name would be "TD101401.600". TD + MMDD + 01 + .XXX. I would like the "+ 01 " to be the number that increments, that way I could have a file that is "TD101402.600" and so forth. Currently if the file exists for the same .XXX number and date combo, it gets overwritten. The .XXX cannot be the increment. </p>
  
  <p>Is this possible?</p>