Macro needed for extracting to Tab

KiloHotel

New Member
Joined
Feb 4, 2018
Messages
42
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
Hi all,

I am wondering if there is a way of extracting a range of cells into seperate tabs from the one long sheet.

Let me give you my issue,

I have one sheet with alot of tables and data, Someone glued it all together and i need each table into separate tabs,

At present it is currently like this:

[TABLE="width: 200"]
<tbody>[TR]
[TD]SOB[/TD]
[TD]BBEE[/TD]
[/TR]
[TR]
[TD]TEST 1[/TD]
[TD]TEST1[/TD]
[/TR]
[TR]
[TD]TEST 2[/TD]
[TD]TEST3[/TD]
[/TR]
[TR]
[TD]TEST 3[/TD]
[TD]TEST3[/TD]
[/TR]
[TR]
[TD]SOB[/TD]
[TD]BBEE[/TD]
[/TR]
[TR]
[TD]TEST11[/TD]
[TD]TEST11[/TD]
[/TR]
[TR]
[TD]TEST12[/TD]
[TD]TEST13[/TD]
[/TR]
</tbody>[/TABLE]


So Anywhere Cell A & B say SOB & BBEE it is a new table all the way down until it says it again. The tables vary in length and they are not all the same. but there is 250+ tables all glued like this (idiotic) but i am screaming for help at this stage if anyone can please


Thanks!
 
SOB is in its own "Merged Cell"
Arrrggg :outtahere:
Merged cells are a complete nightmare & to be avoided at all costs.
If you pick one of the SOB cells what cells are merged?
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Arrrggg :outtahere:
Merged cells are a complete nightmare & to be avoided at all costs.
If you pick one of the SOB cells what cells are merged?


Yeah, I know, This whole file is a bloody nightmare, Cells D,E,F,G,H row 6 is the SOB merged cells then the next SOB merged cells could be row 28 then 66 etc.
 
Upvote 0
The problem may be in that you originally said
So Anywhere Cell A & B say SOB & BBEE
so the code was looking in col A.
Try
Code:
Sub Splitdata()

   Dim Ws As Worksheet
   Dim Ar As Areas
   Dim Rng As Range
   
   Set Ws = ActiveSheet
   With Ws.Range("D1", Ws.Range("D" & Rows.Count).End(xlUp))
      .Replace "SOB", "=XXSOB", xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlConstants).Areas
      .Replace "=XX", "", xlPart, , False, , False, False
      For Each Rng In Ar
         Worksheets.Add , Sheets(Sheets.Count)
         Rng.Offset(-1).Resize(Rng.Count + 1).EntireRow.Copy ActiveSheet.Range("A1")
      Next Rng
   End With
End Sub
 
Upvote 0
The problem may be in that you originally said so the code was looking in col A.
Try
Code:
Sub Splitdata()

   Dim Ws As Worksheet
   Dim Ar As Areas
   Dim Rng As Range
   
   Set Ws = ActiveSheet
   With Ws.Range("D1", Ws.Range("D" & Rows.Count).End(xlUp))
      .Replace "SOB", "=XXSOB", xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlConstants).Areas
      .Replace "=XX", "", xlPart, , False, , False, False
      For Each Rng In Ar
         Worksheets.Add , Sheets(Sheets.Count)
         Rng.Offset(-1).Resize(Rng.Count + 1).EntireRow.Copy ActiveSheet.Range("A1")
      Next Rng
   End With
End Sub

Whoops, Yeah sorry about that!

I ran that one and it created loads of tabs but 500+ and only just chopped info in each one.. :S

Its nearly there, the idea is right but it isn't working just yet!
 
Upvote 0
Do you only have SOB in the "header row" of each section?
 
Upvote 0
Do you only have SOB in the "header row" of each section?

In the Header row it is like this

[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"]SOB[/TD]
[TD="align: center"]BBEE[/TD]
[/TR]
</tbody>[/TABLE]


"SOB" is merged as D to H and "BBEE" is merged I to M, That is the first line of each of these then follows that data in the rows after until it hits that header again indicating the next bit.
 
Upvote 0
Will SOB appear anywhere other than the header?
 
Upvote 0
Ok, do you have formulae in col D? If so will you ever have either TRUE or FALSE in that col?
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,325
Members
453,032
Latest member
Pauh

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