data layout

Manexcel

Board Regular
Joined
Dec 28, 2015
Messages
127
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

titlenamegroupdate
Senior managerJohn Smithgroup101/01/2017
Senior managerjock smithgroup 201/01/2018
Managermary smithgroup 301/01/2019
adminalan smithgroup 401/01/2020

<colgroup><col><col><col><col></colgroup><tbody>
</tbody>


Output after running procedure

grouptitlename
group1Senior managerJohn Smith
group 2Senior managerjock smith
group 3Managermary smith
group 4adminalan smith

<colgroup><col><col><col></colgroup><tbody>
</tbody>

Any thoughts? Thank you.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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,216,030
Messages
6,128,411
Members
449,449
Latest member
Quiet_Nectarine_

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