View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
William[_2_] William[_2_] is offline
external usenet poster
 
Posts: 227
Default Multiple rows to one column

Hi Trip

Assuming your current data is within columns A to Y and columns AA and AB do
not contain any data, try...

Sub test()
Dim r As Range, rr As Range
Dim c As Range, rng As Range
Application.ScreenUpdating = False
With Sheets("Sheet1")
..Range("AA:AB").ClearContents
Set r = .Range(.Range("A1"), _
..Range("A" & Rows.Count).End(xlUp))
For Each c In r
Set rr = .Range(c.Offset(0, 1), c.Offset(0, 24))
Set rng = .Range("AA" & Rows.Count).End(xlUp).Offset(1, 0)
Set rng = .Range(rng, rng.Offset(23, 0))
rng.Formula = c.Value2
rng.Offset(0, 1) = Application.Transpose(rr.Value)
Next c
'Amend next line as appropriate
..Columns("AA:AA").NumberFormat = "dd mmm yy"
..Range("AA1:AB1").Delete Shift:=xlUp
Application.ScreenUpdating = True
End With
End Sub

--
XL2002
Regards

William



"Trip Levert" wrote in message
...
| Each month I get hourly temperature data in this format:
| Row1: 05/01/04 hour1, hour2...
| Row2: 05/02/04 hour1, hour2...
| I need to transpose the columns(hours1 through24)so they
| are listed into one columnthis must be done for each day
| of the month. It should look like:
|
| 05/01/04 hour1
| 05/01/04 hour2
| 05/02/04 hour3...
|
| 05/31/04 hour24
| For the month of May, I would have 744 rows and one
| column. I would like to right code that would do this to
| selected data. I am using Excel 2002. Thanks!
|