Huge file - need to split it into a signle file with tabs based on the value of the rows

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
736
Office Version
  1. 365
Platform
  1. Windows
Imagine a file with about 20,000 rows and each row has product data. The first column has the product name sorted so all the rows for a particular product are in contiguous rows. I need something to split up all the rows for each product into their own tabs - in this file or a new one. It doesn't matter how but I need one file with tabs for each product.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
How about
Code:
Sub SandsB()
   Dim Ary As Variant
   Dim i As Long
   Dim Ws As Worksheet
   
   Application.ScreenUpdating = False
   Set Ws = ActiveSheet
   Ary = Range("A2", Range("A" & Rows.Count).End(xlUp))
   With CreateObject("scripting.dictionary")
      .CompareMode = 1
      For i = 1 To UBound(Ary)
         .Item(Ary(i, 1)) = Empty
      Next i
      For i = 0 To .Count - 1
         Ws.Range("A1").AutoFilter 1, .Keys()(i)
         Worksheets.Add(, Sheets(Sheets.Count)).Name = .Keys()(i)
         Ws.AutoFilter.Range.EntireRow.Copy Range("A1")
      Next i
      Ws.AutoFilterMode = False
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,746
Messages
6,180,705
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top