ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Splitting the contents. (https://www.excelbanter.com/excel-discussion-misc-queries/191211-splitting-contents.html)

Naveed

Splitting the contents.
 
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


joel

Splitting the contents.
 
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


"Naveed" wrote:

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



All times are GMT +1. The time now is 08:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com