split worksheet into separate worksheets based on row content

tbruce

Board Regular
Joined
Dec 9, 2013
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hi,

Hoping someone could help me with this. I've been trying to find a way to do this and just can't get there. What I have is a combined spreadsheet that prior was multiple workbooks/sheets (don't have the original) and was combined into one very large worksheet. Each segment of the worksheet has a header row that starts with SOURCE in the first column (with the same header labels across the row) then about 500 + or - rows of data below it then another header row with SOURCE, etc... I need to break these out to separate workbooks based on the header rows (SOURCE) separation. This appears about 10 times throughout the one worksheet. Hoping someone could point me in the right direction with VBA code or a formula or even a Kutools or ASAP feature.

Here is a small snippet of an example sheet with the combined data and header rows in rows 1 and 6 then so on:

ABCD
1SourceDateTimeActivity
2car2-12-20192240routing
3car5-22-20191304routing
4bicycle6-02-20191134one way
5bicycle7-24-20190700routing
6SourceDateTimeActivity
7car2-03-20190530routing
8car4-02-20190830routing
9bicycle4-25-20191030oe way

<tbody>
</tbody>


Would very much appreciate any guidance on this one.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
How do you want the sheets named?
 
Upvote 0
Ok, how about
Code:
Sub tbruce()
   Dim Ar As Areas
   Dim Rng As Range
   
   With Range("A:A")
      .Replace "Source", "=xxxSource", xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlConstants).Areas
      .Replace "=xxxSource", "Source", xlWhole, , False, , False, False
   End With
   For Each Rng In Ar
      Sheets.Add , Sheets(1)
      Rng.Offset(-1).Resize(Rng.Count + 1).EntireRow.Copy Range("A1")
   Next Rng
End Sub
 
Upvote 0
Hi Fluff - I'm revisiting this and trying another run at a similar dataset, but this time instead of a single word in the header field in column A, I have a variable that changes, but the first two words are always "Search Criteria" then a variety of numbers e.g. " - #####". I can't seem to look for a portion of the cell value. Any suggestions?
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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