View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Transpose random length series of cells

Okay, it looks like you now want the quoted string of comma separated years
in Column C next to (I'm guessing) the first occurrence of each of the
grouped data (so the output will be place in C1, C5 and C7 for your example
code). If that is correct, then the following macro should do what you
want...

Sub GroupData()
Dim X As Long
Dim LastRow As Long
Dim Data As String
Dim Dates As String
Dim Cel As Range
'
Const SheetName As String = "Sheet9"
Const DataStartRow As Long = 1
'
With Worksheets(SheetName)
Set Cel = .Cells(DataStartRow, "A")
Data = Cel.Value
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For X = DataStartRow To LastRow + 1
If Data < .Cells(X, "A").Value Then
Cel.Offset(, 2).Value = """" & Left(Dates, Len(Dates) - 3) & """"
Set Cel = .Cells(X, "A")
Data = Cel.Value
Dates = ""
End If
Dates = Dates & .Cells(X, "B").Value & " , "
Next
End With
End Sub

To implement this code, press Alt+F11 to get into the Visual Basic editor,
click Insert/Module on its menu bar and copy/paste the above code into the
code window that opened. Once you have done that, edit the two separated
Const statements changing my example worksheet name from Sheet9 to the
actual name of the worksheet with your data on it and changing the data
start row from 1 to whatever row your data actually starts on. Now, go back
to the worksheet and press Alt+F8, select GroupData from the list and click
the Run button. You say you have 60,000 rows of data, so I'm guessing the
code will take some time to run (I do not have a feel for how long).

--
Rick (MVP - Excel)


wrote in message
...
Yes, each grouping is together 1.2101R, 10.1101G, etc. in column A,
and the year is in column B in sequential order. Ultimately, what I
need is for the results to be in one cell with some formatting. For
example, results for 1.2101R in C1 (shown in quotes): "1992 , 1993 ,
1994 , 1995" with the spacing and commas.