I have a quite big XLS with information spread over multiple rows that looks like:
TopName Name Mode Item1 Item2 Item3 Item4
-----------------------------------------------------
Foo Name1 ModeX x()
Foo Name2 ModeY x()
Foo Name1 ModeX y()
Foo Name1 ModeX y()
Foo Name2 ModeY y()
What I now want to do is merge the data based on the name into a new sheet or Excel file. The output table should look something like
Name Mode Item1 Item2 Item3 Item4
-------------------------------------------
Name1 ModeX x() y() y()
Name2 ModeY y() x()
I myself will try to come up with a solution via VBA, but there is surely somebody who is way better in that and can maybe post a simple solution?
Update: I tried the following but it does not work at all:
Sub ConsolidateRows()
'takes rows and consolidate one or many cells, based on one or many cells matching with above or below rows.
Dim lastRow As Long, i As Long, j As Long
Dim colMatch As Variant, colConcat As Variant
'**********PARAMETERS TO UPDATE****************
Const strMatch As String = "B" 'columns that need to match for consolidation, separated by commas
Const strConcat As String = "C,D,F,H,I,J,K,L,M,N,O,P,Q,R,S,T,U" 'columns that need consolidating, separated by commas
Const strSep As String = ", " 'string that will separate the consolidated values
'*************END PARAMETERS*******************
Application.ScreenUpdating = False 'disable ScreenUpdating to avoid screen flashes
colMatch = Split(strMatch, ",")
colConcat = Split(strConcat, ",")
lastRow = Range("B" & Rows.Count).End(xlUp).Row 'get last row
For i = lastRow To 4 Step -1 'loop from last Row to one
For j = 0 To UBound(colMatch)
If Cells(i, colMatch(j)) <> Cells(i - 1, colMatch(j)) Then GoTo nxti
Next
For j = 0 To UBound(colConcat)
Cells(i - 1, colConcat(j)) = Cells(i - 1, colConcat(j)) & strSep & Cells(i, colConcat(j))
Next
Rows(i).Delete
nxti:
Next
Application.ScreenUpdating = True 'reenable ScreenUpdating
End Sub
Update2: OK, the file does not even have two matching values in consecutive rows and thus, the code above can obviously not work :( What I need is some kind of dictionary or something...