View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Toppers
 
Posts: n/a
Default Splitting one column into multiple columns

Try:

Sub a()

Dim ws1 As Worksheet, ws2 As Worksheet
Dim lastrow As Long, r As Long, sr As Long
Dim orng As Range

Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")

Set orng = ws2.Cells(1, 1)

r = 1
With ws1
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
Title = "Title" '<=== Change as required
Do
sr = r
Do
r = r + 1
Loop Until .Cells(r, 1) = Title Or r lastrow
orng = .Cells(sr, 1)
.Cells(sr + 1, 1).Resize(r - sr - 1, 1).Copy orng.Offset(1, 0)
Set orng = orng.Offset(0, 1)
Loop Until r lastrow
End With

End Sub

" wrote:

I have a column of text (non-numeric) data that I want to split into
multiple columns whenever the same text appears. What I mean is:

I have:

Title
Info1
Info2
Info3
Info4
Title
Info5
Info6
Info7
Info8
Title
Info9

I want to change that to:

Title Title Title
Info1 Info5 Info9
Info2 Info6
Info3 Info7
Info4 Info8


Ultimately, I will then delete the lower rows of information straight
across the board. Leaving me with:

Title Title Title
Info1 Info5 Info9
Info2 Info6


The "title" is always the same phrase/content.


Is there a macro or VBA code I can use to accomplish this?

Thanks in advance,

PM