Parse spreadsheet into separate tabs in same spreadsheet

JSH720

Board Regular
Joined
Oct 9, 2009
Messages
109
Office Version
  1. 365
Platform
  1. Windows
I have see the answer to this here, but cannot find it now that I need it.

I need to take a very large spreadsheet and make separate tabs in the same spreadsheet based, in this case, on a combination the county and state columns. (each County/State will have a separate tab in the spreadsheet). The county and the state are separate columns.
The large spreadsheet will remain intact.

Any help is appreciated!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Which columns are the county & state in?
 
Upvote 0
It various between spreadsheets, but we can use f and g for this and I can change it as needed.

Thanks.
 
Upvote 0
How about
Code:
Sub JSH720()
   Dim Ws As Worksheet
   Dim Cl As Range
   Dim Ky As Variant
   
   Set Ws = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")
   If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws.Range("F2", Ws.Range("F" & Rows.Count).End(xlUp))
         .Item(Cl.Value & "|" & Cl.Offset(, 1).Value) = Empty
      Next Cl
      For Each Ky In .Keys
         Sheets.Add(, Sheets(Sheets.Count)).Name = Left(Ky, 30)
         Ws.Range("A1:G1").AutoFilter 6, Split(Ky, "|")(0)
         Ws.Range("A1:G1").AutoFilter 7, Split(Ky, "|")(1)
         Ws.AutoFilter.Range.EntireRow.Copy Range("A1")
      Next Ky
   End With
End Sub
Change sheet name in red to suit
 
Upvote 0
Couple of mods to the above code
Code:
Sub JSH720()
   Dim Ws As Worksheet
   Dim Cl As Range
   Dim Ky As Variant
   
   [COLOR=#ff0000]Application.ScreenUpdating = False[/COLOR]
   Set Ws = Sheets("Sheet1")
   If Ws.AutoFilterMode Then Ws.AutoFilterMode = False
   With CreateObject("scripting.dictionary")
      [COLOR=#ff0000].CompareMode = 1[/COLOR]
      For Each Cl In Ws.Range("F2", Ws.Range("F" & Rows.Count).End(xlUp))
         .Item(Cl.Value & "|" & Cl.Offset(, 1).Value) = Empty
      Next Cl
      For Each Ky In .Keys
         Sheets.Add(, Sheets(Sheets.Count)).Name = Left(Ky, 30)
         Ws.Range("A1:G1").AutoFilter 6, Split(Ky, "|")(0)
         Ws.Range("A1:G1").AutoFilter 7, Split(Ky, "|")(1)
         Ws.AutoFilter.Range.EntireRow.Copy Range("A1")
      Next Ky
   End With
   [COLOR=#ff0000]Ws.AutoFilterMode = False[/COLOR]
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,802
Members
449,190
Latest member
cindykay

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