Avatar of finnstone
finnstone
 asked on

comma separated array into rows

long list of rows like the one in the attached in row 1.

i need to split it into two rows as i did in the below cells. sometimes three rows if there are 3 entries in column C separated by col.

as you can see 1st entries in C,D,E go into their own new row. 2nd entries go into a new other row
Book27.xlsx
Microsoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
finnstone

8/22/2022 - Mon
Kimputer

Probably VBA would be the easiest way to go.
Take C2 value, split the comma's, fill those values downwards (same for D and E)
aikimark

Are there ALWAYS the same number of comma separated items in C,D,E?
finnstone

ASKER
no
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
als315

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
finnstone

ASKER
does not show up in macros
als315

It is in worksheet's code
Private Sub split_text_Click()
Dim words_found() As String, prematch() As String, aftermatch() As String
Dim R As Long, R1 As Integer
Dim Res As Worksheet, Src As Worksheet
Dim Str As Range
Dim i As Long, j As Integer
With ActiveWorkbook
    Set Src = .Worksheets("Sheet1") 'Correct name if it is different
    'Add new worksheet for results
    Set Res = .Worksheets.Add
End With
'Fill Headeres
With Src
    .Range("A1:E1").Copy Res.Range("A1:E1")
    Res.Range("A:E").Columns.AutoFit
    R = 2
    R1 = 2
   Do While .Cells(R, 1) <> ""
    words_found = Split(.Cells(R, 3), ",")
    prematch = Split(.Cells(R, 4), ",")
    aftermatch = Split(.Cells(R, 5), ",")
    i = WorksheetFunction.Max(UBound(words_found), UBound(prematch), UBound(aftermatch))
    For j = 0 To i
        .Range("A" & R & ":B" & R).Copy Res.Range("A" & R1)
        If UBound(words_found) >= j Then Res.Cells(R1, 3) = words_found(j)
        If UBound(prematch) >= j Then Res.Cells(R1, 4) = prematch(j)
        If UBound(aftermatch) >= j Then Res.Cells(R1, 5) = aftermatch(j)
        R1 = R1 + 1
    Next j
    R = R + 1
   Loop
End With
End Sub

Open in new window

finnstone

ASKER
there is no macro
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
als315

Can you press button? Are macros enabled?
Macro you can find here (press Alt+F11 to show vba editor):
macro
aikimark

No
Then what is/are the rule(s) for parsing this into multiple rows?
finnstone

ASKER
sorry must have been wrong setting ony my other computer.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
finnstone

ASKER
thx!!