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:

SOBBBEE
TEST 1TEST1
TEST 2TEST3
TEST 3TEST3
SOBBBEE
TEST11TEST11
TEST12TEST13

<tbody>
</tbody>


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 :coffee:
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

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Arrrggg :coffee:
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

SOBBBEE

<tbody>
</tbody>


"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,215,135
Messages
6,123,239
Members
449,093
Latest member
Vincent Khandagale

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