Splitting a long row into small multiple rows

sunilrd99

New Member
Joined
Jul 11, 2011
Messages
2
Hello,

I have a excel data like A1,A2,A3............A99 IN THE RESP. CELLS of row 1.

What i need to do is split this row in to multiple rows containing data as below.
Row1: A1,A2,A3
Row2: A1,A2,A4
Row3: A1,A2,A5
Row4 A1,A2,A6

(A1 and A2 being constant. information, need to be duplicated in each row)

Can any body help me. Thanks in advance to the attempter!
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
I think this macro does what you want...
Code:
Sub SplitDataDownward()
  Dim ACell As String, Common As String, Joined As String, Parts() As String
  ACell = Range("A1").Value
  Parts = Split(ACell, ",", 3)
  Common = Parts(0) & "," & Parts(1) & ","
  Parts = Split(Parts(2), ",")
  Joined = Common & Join(Parts, Chr(1) & Common)
  Parts = Split(Joined, Chr(1))
  Range("A1").Resize(UBound(Parts) + 1) = WorksheetFunction.Transpose(Parts)
End Sub
 
Upvote 0
I just reread your question and think I may have misinterpretted originally. I thought you had your A1,A2,A3,etc. all in A1, but in rereading your posting, I think you have A1 in cell A1, A2 in cell B1, A3 in cell C1, etc. If that is the case, then give this macro a try...

Code:
Sub SplitDataDownward()
  Dim ACell As String, Common As String, Joined As String, Parts() As String
  With WorksheetFunction
    ACell = .Trim(Join(.Index(Range(Cells(1, "A"), Cells(1, 1).End(xlToRight)).Value, 1, 0), ","))
    Rows(1).ClearContents
  End With
  Parts = Split(ACell, ",", 3)
  Common = Parts(0) & "," & Parts(1) & ","
  Parts = Split(Parts(2), ",")
  Joined = Common & Join(Parts, Chr(1) & Common)
  Parts = Split(Joined, Chr(1))
  Range("A1").Resize(UBound(Parts) + 1) = WorksheetFunction.Transpose(Parts)
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top