Excel Macro to replicate cells

Can you please help,
is there an Excel macro that can replicate/ copy range of cells to after the last row.

Basically, take a cell (Column "A8:A"), and if it has more than one value (commas in between), copy range cells to after last used Row.

please see samples attached. -- Before and After ---

Your help is appreciated,
Who is Participating?

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

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.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Try the following code. For details, refer to the attached workbook with three Test Sheets. You may click the button ReArrange Data on each Test Sheet to run the code in order to get the desired output.

Sub RearrangeData()
Dim rng As Range, cell As Range
Dim lr As Long
Dim str() As String
Application.ScreenUpdating = False
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("A9:A" & lr)

For Each cell In rng
   cell = Replace(Replace(cell, "(", ""), ")", "")
   If InStr(cell, ",") > 0 Then
      str() = Split(cell, ",")
      cell.Offset(1, 0).Resize(UBound(str)).EntireRow.Insert
      Range(Cells(cell.Row, "B"), Cells(cell.Row, "E")).Copy
      For i = 0 To UBound(str)
         cell.Offset(i, 0) = str(i)
         cell.Offset(i, 1).PasteSpecial xlPasteValues
      Next i
   End If
Next cell
Application.ScreenUpdating = True
MsgBox "Finished.", vbInformation
End Sub

Open in new window


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
W.E.BAuthor Commented:
Thank you very much
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome. Glad 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 Excel

From novice to tech pro — start learning today.