Create New Sheet , multiple rows per original sheet row

Excelconfused1

New Member
Joined
Feb 27, 2019
Messages
3
I am only just starting to learn how to do VBA Excel macrosand I would like to create a macro to do the following:


If I have rows of data as follows (simplified), in a sheet called "Dependencies":

Column: A B C D E F G

Headings: Service Dep1 Cat1 Dep2 Cat2 Dep3 Cat3.

Row 1 A B U C U E D

Row 2 B A U G D H D



I would like to copy the data to new rows in a new sheet inthe workbook (sheet name "Expanded" as follows:


Service Dep Cat
A B U
A C U
A E D
B A U
B G D
B H D

In other words, separate out the Cat / Dep occurrences ineach row from "Dependencies" so each Cat/ Dep occurrence appears in its own row in the "Expanded" sheet.

I have 50 occurrences for each row. I only want to createentries in the new sheet where they are not blank in the original sheet.

There are about 200 rows I need to convert in this way.

How would I code this?

Thanks in advance.

 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I don't follow your description of the data. Is ABUCUED all in a single cell? Is that the only data you want separated into a new worksheet? Do all of the departments have the same number of letters?
 
Upvote 0
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Service
[/TD]
[TD]Dep1
[/TD]
[TD]Cat1
[/TD]
[TD]Dep2
[/TD]
[TD]Cat2
[/TD]
[TD]Dep3
[/TD]
[TD]Cat3
[/TD]
[/TR]
[TR]
[TD]AAA
[/TD]
[TD]BBB
[/TD]
[TD]D
[/TD]
[TD]CCC
[/TD]
[TD]U
[/TD]
[TD]EEE
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]BBB
[/TD]
[TD]EEE
[/TD]
[TD]U
[/TD]
[TD]FFF
[/TD]
[TD]D
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Apologies.

Formatting didn't work in my original post....

All tabs and extra spaces were removed....

Basically, I need a macro to convert the sheet above to the following:
 
Upvote 0
[TABLE="width: 500"]
<tbody>[TR]
[TD]Service
[/TD]
[TD]Dep
[/TD]
[TD]Cat
[/TD]
[/TR]
[TR]
[TD]AAA
[/TD]
[TD]BBB
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]AAA
[/TD]
[TD]CCC
[/TD]
[TD]U
[/TD]
[/TR]
[TR]
[TD]AAA
[/TD]
[TD]EEE
[/TD]
[TD]D
[/TD]
[/TR]
[TR]
[TD]BBB
[/TD]
[TD]EEE
[/TD]
[TD]U
[/TD]
[/TR]
[TR]
[TD]BBB
[/TD]
[TD]FFF
[/TD]
[TD]D
[/TD]
[/TR]
</tbody>[/TABLE]

There are about 200 rows in the source table with up to 50 occurences of Dep / Cat per row,
Text is variable length in Service and Dep.

Thanks in advance.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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