title: How to create a new Workbook for each unique value in a column?
body: <p>I need to run a foreach statement for each unique value in column J. For each unique name, I want to create a new Excel Workbook copy all the rows for the specific name and finally save the workbook with the same unique value.</p>
  
  <pre><code>Sub test()
  Range("A1:J17").Select
  Selection.Copy
  Workbooks.Add
  ActiveSheet.Paste
  Cells.Select
  Cells.EntireColumn.AutoFit
  Application.CutCopyMode = False
  Range("D1").Select
  Selection.Copy
  ChDir "c:\test"
  ActiveWorkbook.SaveAs Filename:= _
      "c:\test\test.xlsx", _
      FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
  End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/8VdkI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8VdkI.png" alt="enter image description here"></a></p>