Hello,
I've got problem with excel task. I need to compress rows for specific ID number ( its like 50k record). For 1 spec ID for now its 12 rows and I'd like to insert all this data to 1 row, for now i don't know how to solve this, please help me![]()
Hello,
I've got problem with excel task. I need to compress rows for specific ID number ( its like 50k record). For 1 spec ID for now its 12 rows and I'd like to insert all this data to 1 row, for now i don't know how to solve this, please help me![]()
is expected output one very long row for each ID?
It wil be a) very tough to read b) even tougher to process
3 additional questions:
- will there be always 12 rows for each ID? or could it change - some ID's with less, or may be some with more rows?
- will start and end dates (columns B and C) have the same values within single ID?
- why do you put texts just looking as dates, not real excel dates in column B?
Best Regards,
Kaper
Don't know why you cannot answer in the thread (as you reported in PM), but the solution could be such code:
See also attached file![]()
Sub collate_rows() Dim rows_to_delete As Range, current_row As Long, previous_ID As String Dim row_in_sequence As Long, max_row_in_sequence As Long For current_row = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1 If Cells(current_row, "A") <> previous_ID Then row_in_sequence = 1 previous_ID = Cells(current_row, "A") Else Cells(current_row, "T").Resize(1, 16 * row_in_sequence).Value = Cells(current_row + 1, "D").Resize(1, 16 * row_in_sequence).Value row_in_sequence = row_in_sequence + 1 If row_in_sequence > max_row_in_sequence Then max_row_in_sequence = row_in_sequence If rows_to_delete Is Nothing Then Set rows_to_delete = Rows(current_row + 1) Else Set rows_to_delete = Union(rows_to_delete, Rows(current_row + 1)) End If End If Next current_row If Not (rows_to_delete Is Nothing) Then rows_to_delete.Delete Cells(1, "D").Resize(1, 16).AutoFill Cells(1, "D").Resize(1, 16 * max_row_in_sequence) End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks