View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default One column to multiple columns - with a twist

Are all those values just plain old constants--not formulas???

Option Explicit
Sub testme()

Dim myRng As Range
Dim myArea As Range
Dim CurWks As Worksheet
Dim NewWks As Worksheet
Dim oCol As Long

Set CurWks = Worksheets("sheet1")
Set NewWks = Worksheets.Add

With CurWks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("a:a").Cells.SpecialCells(xlCellTypeConstan ts)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No constants"
Exit Sub
End If

oCol = 0
For Each myArea In myRng.Areas
oCol = oCol + 1
myArea.Copy _
Destination:=NewWks.Cells(1, oCol)
Next myArea
End With

End Sub




Tenacious Lee wrote:

Hello to all Excel experts in internet-land,

I have an interesting twist on a problem that has been solved in lots
of previous posts. I have a huge column of numerical data, with
'chunks' of cells of data separated by variably-sized 'chunks' of blank
cells. I would like to be able to apply a macro that will wade through
the data, splitting the big column into multiple columns, with each
'chunk' of data in its own individual column. Hopefully this will
clarify things for you:

Raw data:

1
2
3
4

4
5
7

12
3
5
67
7

Finished product:

1 4 12
2 5 3
3 7 5
4 67
7

Any help or code snippets from a curious expert would be greatly
appreciated!


--

Dave Peterson