Splitting the contents.

N

Naveed

I need to split the contets of column B and paste it in the rows
automatically. (As in the Answer below.

Question
Cloumn A Column B
EQ097-011210 EQ097-011202, EQ097-011203, EQ097-011204

Answer
EQ097-011210 EQ097-011202
EQ097-011203
EQ097-011204
 
J

Joel

You need a macro like the one below

Sub SplitCol()

LastRow = Range("B" & Rows.Count).End(xlUp).Row
RowCount = 1
Do While RowCount <= LastRow
If InStr(Range("B" & RowCount), ",") > 0 Then
Rows(RowCount + 1).Insert

Rowdata = Range("B" & RowCount)
Range("B" & RowCount) = _
Trim(Left(Rowdata, InStr(Rowdata, ",") - 1))
Range("B" & (RowCount + 1)) = _
Trim(Mid(Rowdata, InStr(Rowdata, ",") + 1))
LastRow = LastRow + 1
End If
RowCount = RowCount + 1
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top