Change Excel data from single row to columns

Hi EE .. can someone help me convert this with a Macro or Powershell ?

The data in Column B is separated by a comma

Column A , Column B
Person1      Order1,Order2,Order3,Order4


Can someone help me convert this to ?

Column A , Column B
Person1    Order1
Person1    Order2
Person1    Order3
Person1    Order4
LVL 2
MilesLoganAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ShumsExcel & VBA ExpertCommented:
Try below:

It will return your expected result in Sheet2
Sub SplitColB()
Dim Ws1 As Worksheet, Ws2 As Worksheet
Dim Rng As Range, SplitRng As Range, c As Range
Dim LRow As Long
Dim i As Integer
Dim Txt As String
Dim Orig As Variant

Set Ws1 = Worksheets("Sheet1")
Set Ws2 = Worksheets("Sheet2")
LRow = Ws1.Range("A" & Rows.Count).End(xlUp).Row
Set Rng = Ws1.Range("A2:A" & LRow)
Ws2.Cells.ClearContents
Ws2.Range("A1").Value = "ColumnA"
Ws2.Range("B1").Value = "ColumnB"

With Application
    .ScreenUpdating = False
    .DisplayStatusBar = True
    .StatusBar = "!!! Please Be Patient...Updating Records !!!"
    .EnableEvents = False
    .Calculation = xlCalculationManual
End With
For Each c In Rng.Cells
    Set SplitRng = c.Offset(, 1)
    Txt = SplitRng.Value
    Orig = Split(Txt, ",")
    For i = 0 To UBound(Orig)
        Ws2.Cells(Rows.Count, "A").End(xlUp).Offset(1) = Trim(c)
        Ws2.Cells(Rows.Count, "A").End(xlUp).Offset(, 1) = Trim(Orig(i))
    Next i
Next c
Ws2.Activate
Ws2.UsedRange.Columns("B:B").AutoFit
Ws2.Range("A1").Select
With Application
    .ScreenUpdating = True
    .DisplayStatusBar = True
    .StatusBar = False
    .EnableEvents = True
    .Calculation = xlCalculationAutomatic
End With
End Sub

Open in new window

Check in attached...
MilesLogan_SplitCellsToRows.xlsm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MilesLoganAuthor Commented:
Hi Shumns .. That is pretty cool !! thank you so much for your assistance .
ShumsExcel & VBA ExpertCommented:
You're Welcome! Glad I was able to help :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.