title: Need to change one little thing in this macro
body: <p>I have this macro which does exactly what I want except for one change. I want it to sort by column "M" instead of "A". I've tried changing it manually, but I keep getting errors. I know it's probably a simple fix but I just can't seem to get it. Thanks in advance!</p>
  
  <p>I've tried to change "Field:=1" to Field:="13", but I get "Run-time error '1004' AutoFilter method of range class failed".</p>
  
  <p>Debug then highlights "rngFilter.AutoFilter Field:=13, Criteria1:=cell.Value"</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  
  
  Dim wbDest As Workbook
  Dim rngFilter As Range, rngUniques As Range
  Dim cell As Range
  
  
  Set rngFilter = Range("A1", Range("A" &amp; Rows.Count).End(xlUp))
  
  Application.ScreenUpdating = False
  
  With rngFilter
  
  
      .AdvancedFilter Action:=xlFilterInPlace, Unique:=True
  
  
      Set rngUniques = Range("A2", Range("A" &amp; Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible)
  
  
      ActiveSheet.ShowAllData
  
  End With
  
  
  For Each cell In rngUniques
  
  
      Set wbDest = Workbooks.Add(xlWBATWorksheet)
  
  
      rngFilter.AutoFilter Field:=1, Criteria1:=cell.Value
  
  
      rngFilter.EntireRow.Copy
      With wbDest.Sheets(1).Range("A1")
          .PasteSpecial xlPasteColumnWidths
          .PasteSpecial xlPasteValuesAndNumberFormats
      End With
      Application.CutCopyMode = True
  
  
      wbDest.Sheets(1).Name = cell.Value
  
  
      wbDest.SaveAs ThisWorkbook.Path &amp; Application.PathSeparator &amp; _
          cell.Value &amp; " " &amp; Format(Date, "mmm_dd_yyyy")
  
  Next cell
  
  rngFilter.Parent.AutoFilterMode = False
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>