MS Excel dividing rows by a sort column

I have an Excel spreadsheet with 15,000+ rows with 15 columns and it is sorted by BillToMfgName, MfgName, StoreNbr, Category, and ItemId.  Is there a way (macro or some other) to automate the seperation of all rows for one manufacturer by the BillToMfgName column and put that information into a new spreadsheet?  And do this for each BillToMfgName in some type of automated way?

Thanks in advance for the help.

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

byundtConnect With a Mentor Commented:
Here is a macro that uses Advanced Filter to capture a list of unique BillToMfgName, then uses AutoFilter to filter your data for each manufacturer in turn. The filtered data is copied to a new worksheet named after the manufacturer.

As written, the macro runs on the active worksheet, and assumes that your data are surrounded by empty rows and columns.
Sub BillToMfgToWorksheets()
Dim cel As Range, rg As Range, rgFilt As Range, rgUniques As Range
Dim iCol As Long
Dim v As Variant, vUniques As Variant
Dim ws As Worksheet
Application.ScreenUpdating = False
Set cel = ActiveCell
Set rg = ActiveSheet.Range("A1").CurrentRegion  'All the raw data
v = Application.Match("BillToMfgName", rg.Rows(1), 0)
If IsError(v) Then Exit Sub

iCol = v
Set rgUniques = rg.Cells(1, 1).Offset(0, rg.Columns.Count + 2)
Set rgFilt = rg.Columns(iCol)
rgFilt.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=rgUniques, Unique:=True
Set rgUniques = rgUniques.Resize(rgUniques.CurrentRegion.Rows.Count, 1)
vUniques = rgUniques.Offset(1, 0).Resize(rgUniques.Rows.Count - 1).Value
If rgUniques.Rows.Count = 1 Then Exit Sub

For Each v In vUniques
    rg.AutoFilter Field:=iCol, Criteria1:=v
    Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
    ws.Name = v
    rg.Copy ws.Range("A1")
Application.Goto cel
End Sub

Open in new window

Here is a sample workbook containing the macro. Push the button to see it in action.

The macro is installed on a regular module sheet.

If you want to test the macro with your data, just paste it over my test data.
All Courses

From novice to tech pro — start learning today.