Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default One column to multiple columns - with a twist

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default One column to multiple columns - with a twist

Sub SeparateColumns()
dim rng as Range, ar as Range
dim col as Long
col = 2
set rng = columns(1).SpecialCells(xlConstants)
if rng.Areas.count 255 then
msgbox "too many blocks"
exit sub
end if

for each ar in rng.Areas
ar.copy cells(1,col)
col = col + 1
Next ar
' columns(1).Delete
End sub

--
Regards,
Tom Ogilvy

"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!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default One column to multiple columns - with a twist

Good gracious you guys rock.

Thanks for the prompt (and spot-on) response.

-Lee

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Rows to columns with a twist bcone Excel Discussion (Misc queries) 1 June 11th 08 10:42 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 2 July 31st 06 09:45 PM
Combine multiple columns into two long columns, Repeating rows in first column [email protected] Excel Discussion (Misc queries) 0 July 31st 06 05:07 PM
Compare 2 columns to a 3rd with a twist. Celt[_34_] Excel Programming 8 March 31st 06 01:04 AM
Multiple Arguments - New Twist dansargeant Excel Worksheet Functions 2 March 10th 06 03:28 PM


All times are GMT +1. The time now is 07:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"