data layout

Manexcel

Board Regular
Joined
Dec 28, 2015
Messages
128
Office Version
  1. 365
Platform
  1. Windows
I have a dataset that is grouped by level which I wish to re format onto another worksheet. An example is below:

Existing dataset

ColA ColB ColC
Level 1
Space
name1 group1 L1111
Space
Level 2
space
Name2 group2 C2222
Name3 group3 L3333
Name4 group4 L4444
space
Level 3
space
Name5 group5 L5555
Name6 group6 L6666
etc
Name20 group20 L2020

Is it possible to have a formula that will format / group the above dataset as follows (each group could have a maximum of say 20):

Required output

ColA ColB ColC ColD

Level1 name 1 group 1 L1111
Level2 name2 group2 C2222
name3 group3 L3333
name4 group4 L4444
Level3 name5 group5 C5555
name6 group6 L6666
name20 group20 L2020
etc

I thank you for time and understanding.
 
Thank you for the procedure. The procedure deleted Col D. It moved "group" - Col C to Col A and ended. "Title" is now in Col B. "name" is in Col C.

Test dataset

ColA ColB ColC ColD

[TABLE="width: 309"]
<colgroup><col><col><col><col></colgroup><tbody>[TR]
[TD]title[/TD]
[TD]name[/TD]
[TD]group[/TD]
[TD]date[/TD]
[/TR]
[TR]
[TD]Senior manager[/TD]
[TD]John Smith[/TD]
[TD]group1[/TD]
[TD="align: right"]01/01/2017[/TD]
[/TR]
[TR]
[TD]Senior manager[/TD]
[TD]jock smith[/TD]
[TD]group 2[/TD]
[TD="align: right"]01/01/2018[/TD]
[/TR]
[TR]
[TD]Manager[/TD]
[TD]mary smith[/TD]
[TD]group 3[/TD]
[TD="align: right"]01/01/2019[/TD]
[/TR]
[TR]
[TD]admin[/TD]
[TD]alan smith[/TD]
[TD]group 4[/TD]
[TD="align: right"]01/01/2020[/TD]
[/TR]
</tbody>[/TABLE]


Output after running procedure

[TABLE="width: 234"]
<colgroup><col><col><col></colgroup><tbody>[TR]
[TD]group[/TD]
[TD]title[/TD]
[TD]name[/TD]
[/TR]
[TR]
[TD]group1[/TD]
[TD]Senior manager[/TD]
[TD]John Smith[/TD]
[/TR]
[TR]
[TD]group 2[/TD]
[TD]Senior manager[/TD]
[TD]jock smith[/TD]
[/TR]
[TR]
[TD]group 3[/TD]
[TD]Manager[/TD]
[TD]mary smith[/TD]
[/TR]
[TR]
[TD]group 4[/TD]
[TD]admin[/TD]
[TD]alan smith[/TD]
[/TR]
</tbody>[/TABLE]

Any thoughts? Thank you.
 
Upvote 0

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
The code in post#10 replaces the SplitData code I originally supplied, in a previous thread. And should be run on your original data.
If it's not working can you please let me know what it's doing wrong.
 
Upvote 0
I run the procedure against the original dataset. I had one or two attempts on the grouping but eventually changed the column for the grouping to Col C and the output was as I expected. But the procedure did delete Col D which I would like to keep. (I couldn't see how to add this to the procedure?)

Also, is it possible to create the output onto another sheet instead of same sheet?

Thank you so much for all your time and patience it is very much appreciated.
 
Upvote 0
OK, add these 2 lines to the beginning of the code, this will create a sheet called New, with the data.
Code:
   ActiveSheet.Copy after:=Sheets(Sheets.Count)
   ActiveSheet.Name = "New"
and remove this line, which deletes the column
Code:
Columns(4).Delete
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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