Multiple comma delimited date parsed to separate rows

YaYa08

New Member
Joined
Oct 22, 2015
Messages
30
Column A has multiple Cust parts. I need to separate the Cust part to individual rows with the other data in the columns matched.

Here is an example of the first row as it should appear:


Excel 2010
GHIJK
1Cust partOur partsOur IDCurrencyPrice
2135649A1Part AD100110399USD$ 18.95
3A75262Part AD100110399USD$ 18.95
Example



Here is my data:


Excel 2010
ABCDE
1Cust partOur partsOur IDCurrencyPrice
2135649A1, A75262Part AD100110399USD$18.95
3138642, BN98510, 190585R91Part O100027144USD$ 7.82
4163044, BN98509Part W100026523USD$ 4.57
5179080, BSET2Part U100045902USD$ 3.97
618427, ST791Part P100047915USD$ 7.82
721076D, E3NN3123AA, 210760Part N100050683USD$ 3.66
844401, 694735 CONE, ST775APart C100055719USD$ 6.44
9459456R91, 86576982 - CONE, 273423Part L100096658USD$ 3.83
1047508360, 52443, 664175R92Part F100081326USD$13.22
Example
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Code:
Sub parsetranspose()
Dim x%, y%, partarray As Variant
x = 2
Do Until Cells(x, 1).Value = ""
y = Evaluate("=LEN(A" & x & ")-LEN(SUBSTITUTE(A" & x & ","","",""""))")
ReDim partarray(y)
partarray = Split(Cells(x, 1).Value, ",")
Rows(x + 1).Resize(y).Insert
Range("A" & x).Resize(y + 1).Value = Application.Transpose(partarray)
Range("B" & x & ":E" & x).Resize(y + 1).Value = Range("B" & x & ":E" & x).Value
x = x + y + 1
Loop
End Sub
 
Upvote 0
you don't need the evaluate, those functions are also available in vba

y = Len(Cells(x, 1)) - Len(Replace(Cells(x, 1).Value, ",", ""))
 
Last edited:
Upvote 0
you don't need the evaluate, those functions are also available in vba

y = Len(Cells(x, 1)) - Len(Replace(Cells(x, 1).Value, ",", ""))



I'm not sure I understand. The previous vba code you provided works so how does this affect what you already provided?
 
Upvote 0
Nevermind about my comment to explain the "evaluate" code. I figured it out.

One more question. Not all the "Cust Part" need to be parsed because they may only contain 1 Cust Part.

The code works if there are always Cust Part(s) with a comma but I am getting the following error at:

Rows(x + 1).Resize(y).Insert

Can you please provide the necessary adjustment for when the Cust Part field does not contain a comma . Thanks for your help and expertise!
 
Last edited:
Upvote 0
This?

Code:
Sub parsetranspose()
Dim x%, y%, partarray As Variant
x = 2
Do Until Cells(x, 1).Value = ""
y = Len(Cells(x, 1)) - Len(Replace(Cells(x, 1).Value, ",", ""))
If y > 0 Then
ReDim partarray(y)
partarray = Split(Cells(x, 1).Value, ",")
Rows(x + 1).Resize(y).Insert
Range("A" & x).Resize(y + 1).Value = Application.Transpose(partarray)
Range("B" & x & ":E" & x).Resize(y + 1).Value = Range("B" & x & ":E" & x).Value
Else
End If
x = x + y + 1
Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,543
Messages
6,160,421
Members
451,644
Latest member
hglymph

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