Question : Splitting Excel Worksheet into Multiple workbooks

Hi,

I currently have an excel spreadsheet with several columns in it.  One of the columns is Customer.  I would like to split out each Customer into a separate workbook so that I can email each workbook to each customer.  Is there a simple way of doing this?  Ideally I would love to be able to automate this function.

Thanks

Answer : Splitting Excel Worksheet into Multiple workbooks

Try this.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
Sub x()
 
Dim rng As Range, ws As Worksheet

Application.DisplayAlerts = False

With Sheets("Sheet1")
    Sheets.Add().Name = "temp"
    .Range("A1", .Range("A" & Rows.Count).End(xlUp)).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Sheets("temp").Range("A1"), Unique:=True
     For Each rng In Sheets("temp").Range("A2", Sheets("temp").Range("A2").End(xlDown))
        Set ws = Worksheets.Add()
        ws.Name = rng
        .AutoFilterMode = False
        .Range("A1").AutoFilter field:=1, Criteria1:=rng
        .AutoFilter.Range.Copy ws.Range("A1")
        ws.Move
        ActiveWorkbook.Close SaveChanges:=True, Filename:="C:\" & rng & ".xls"
    Next rng
    .AutoFilterMode = False
    Sheets("temp").Delete
End With
     
Application.DisplayAlerts = True

End Sub
Random Solutions  
 
programming4us programming4us