title: Excel VBA Macro to filter the file and copy it on new workbook
body: <p>I am very new to VBA programming and trying to write a VBA code in excel This code will filter my file by <code>Criteria1:="=*001"</code> and copy all the unique value to new workbook named AV and save it. Now, I also want to copy all the values where <code>Criteria1:="&lt;&gt;*001"</code> to new workbook named LC and save it.</p>
  
  <p>Here is the code I found on this website and tried to modified it but not sure how to use <code>ELSE</code> for <code>Criteria1:="&lt;&gt;*001"</code>.</p>
  
  <pre><code>Sub sort()
  On Error Resume Next
  Application.DisplayAlerts = False
  
  Dim new_book As Workbook
  Dim newsheet As Worksheet
  
  With ThisWorkbook.Sheets("NRM_Homing_Upload")  'Replace the sheet name with the raw data sheet name
  
      Set newsheet = ThisWorkbook.Sheets("TempSheet")
  
          If newsheet Is Nothing Then
                  Worksheets.Add.Name = "TempSheet"
              Else
                  ThisWorkbook.Sheets("TempSheet").Delete
                  Worksheets.Add.Name = "TempSheet"
          End If
  
              .Columns("H").Copy
  
                  With ThisWorkbook.Sheets("cal")
                      .Range("A1").PasteSpecial (xlPasteAll)
                      .Columns("H").RemoveDuplicates Columns:=1, Header:=xlYes
                  End With
  
                          For Each cell In ThisWorkbook.Sheets("TempSheet").Columns("a").Cells
                              i = i + 1
                                  If i &lt;&gt; 1 And cell.Value &lt;&gt; "" Then
                                      .AutoFilterMode = False
                                      .Rows(1).AutoFilter field:=8, Criteria1:="=*001"
                                      Set new_book = Workbooks.Add
                                      .UsedRange.Copy
                                      new_book.Sheets(1).Range("a1").PasteSpecial (xlPasteAll)
                                      'new_book.SaveAs Filename:=ThisWorkbook.Path &amp; "\" &amp; cell.Value &amp; ".xlsx"
                                      new_book.SaveAs Filename:="C:\Desktop\excel\test\AV.xlsx"
                                      new_book.Sheets(1).UsedRange.Columns.AutoFit
                                      new_book.Save
                                      new_book.Close
  
                                  End If
                          Next cell
  
  
  
                              ThisWorkbook.Sheets("TempSheet").Delete
  End With
  
  End Sub
  </code></pre>
  
  <p>Any help is appreciated. 
  Thanks</p>