I am trying to get this to sort out to a new workbook instead of a worksheet. There are only two components in C column, so there should only be 2 new workbooks created. I am a little unfamiliar with the terminology for the workbooks. Thank you.
Sub SplitOut()
Dim DataSH As Worksheet, OutSH As Worksheet
Set DataSH = Sheets("Input")
DataSH.Activate
lastrow = Cells(Rows.Count, "C").End(xlUp).Row
For Each ce In Range("C2:C" & lastrow)
Application.StatusBar = "Actioning " & ce.Row & " of " & lastrow
On Error Resume Next
Set OutSH = Nothing
Set OutSH = Sheets(ce.Value)
On Error GoTo 0
If OutSH Is Nothing Then 'the sheet doesn't exist
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = ce.Value
ActiveSheet.Range("A1:N1").Value = DataSH.Range("A1:N1").Value
Set OutSH = ActiveSheet
End If
outrow = OutSH.Cells(Rows.Count, "D").End(xlUp).Offset(1, 0).Row
ce.EntireRow.Copy Destination:=OutSH.Cells(outrow, 1)
Next ce
Application.StatusBar = False
MsgBox "Done"
End Sub
Bookmarks