Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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. |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Rick: That worked fabulously! Ironically, it also highlighted some
quirks in my dataset. Most of the time my data only has one series of years, but every so often there's more than one series of years. Here's an example with the results of your VB code in column C Col A Col B Col C 11.7102R 1979 "1979 , 1980 , 1981 , 1982 , 1983 , 1984 , 1985" 11.7102R 1980 11.7102R 1981 11.7102R 1982 11.7102R 1983 11.7102R 1984 11.7102R 1985 12.3101G 1966 "1966 , 1967 , 1968 , 1969 , 1970 , 1971 , 1972 , 1973 , 1974 , 1975 , 1968 , 1969 , 1970 , 1971 , 1971 , 1972 , 1973 , 1974" 12.3101G 1967 12.3101G 1968 12.3101G 1969 12.3101G 1970 12.3101G 1971 12.3101G 1972 12.3101G 1973 12.3101G 1974 12.3101G 1975 12.3101G 1968 12.3101G 1969 12.3101G 1970 12.3101G 1971 12.3101G 1971 12.3101G 1972 12.3101G 1973 12.3101G 1974 You can see that 11.7102R only has one series of years, but 12.3101g has three different series of years. I need the years pulled out each time the series of years starts over. I.e. for 12.3101g 1966 though 75 and 12.3101g for 1968-71 and 12.3101g for 71-74 |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Also, I just attempted to run it on the entire dataset, and am getting
a "out of memory" error. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Transpose random series of cells | Excel Worksheet Functions | |||
Transpose random series of cells | Excel Worksheet Functions | |||
Transpose a variable length list into Excel / Access Table | New Users to Excel | |||
Variable series length/range | Charts and Charting in Excel | |||
Plotting different length series in a chart | Charts and Charting in Excel |