Macro help - copy row, split data into multiple rows to create multiple entires for each row

michelleW888

New Member
Joined
Nov 16, 2010
Messages
3
Hoping someone can help with this complicated Macros. I need to Macro help - copy row, split data into multiple rows to create multiple entires for each row.

I need to create a new row that copies model, type and size data and splits color code and quantity into separate rows.

This is the data I currently have:

Model
Type Color Code Size Qty
A half C1,C2,C4,C6,C7 53-29 4,6,7,3,8
B circle C111,C146 54-26 10,5
C whole C1,C7 54-30 6,6



These rows would be replaced by the following rows:

Model Type Color Code Size Qty
A half C1 53-29 4
A half C2 53-29 6
A half C4 53-29 7
A half C6 53-29 3
A half C7 53-29 8
B circle C111 54-26 10
B circle C146 54-26 5
C whole C1 54-30 6
C whole C7 54-30 6
 
Last edited:

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
updating with aligned excel columns:

these are the columns I am working with:

Excel Workbook
ABCDE
3AhalfC1,C2,C4,C6,C753-294,6,7,3,8
4BcircleC111,C14654-2610,5
5CwholeC1,C754-306,6
Sheet1





These rows would be replaced by the following rows:

Excel Workbook
ABCDE
11AhalfC153-294
12AhalfC253-296
13AhalfC453-297
14AhalfC653-293
15AhalfC753-298
16BcircleC11154-2610
17BcircleC14654-17-140,54-265
18CwholeC154-306
19CwholeC754-306
Sheet1
 
Upvote 0
I don't know how you arrive at the result in D17 but try this with Sheet1 selected. Results in Sheet2.

Code:
Sub Michelle()
Dim LR As Long, i As Long, j As Integer, X, Y
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 3 To LR
    X = Split(Range("C" & i).Value, ",")
    Y = Split(Range("E" & i).Value, ",")
    For j = LBound(X) To UBound(X)
        Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1).Value = Range("A" & i).Value
        Sheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1).Value = Range("B" & i).Value
        Sheets("Sheet2").Range("C" & Rows.Count).End(xlUp).Offset(1).Value = X(j)
        Sheets("Sheet2").Range("D" & Rows.Count).End(xlUp).Offset(1).Value = Range("D" & i).Value
        Sheets("Sheet2").Range("E" & Rows.Count).End(xlUp).Offset(1).Value = Y(j)
    Next j
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,196
Members
449,072
Latest member
DW Draft

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