Reputation: 703
I have an excel table that looks like this:
I need to be able to reformat it automatically like so:
I've tried every possible formula, and every possible variation of a pivot table but can't find anything that even remotely gets me to where I want to be. For example, adding Vlookups in additional columns and then generating 4 tables and merging is too manual for this to be workable. Tried using index/match, that also didn't work out as it is too manual. In real life, this table would vary in size, so adjusting the "reformatted" table is not really optimum. Any ideas, suggestions are more than welcome!
Upvotes: 0
Views: 1370
Reputation: 96753
With data like:
This short macro:
Sub ReOrganizeData()
Dim i As Long, j As Long, K As Long, N As Long
Dim v As Variant
N = Cells(Rows.Count, "A").End(xlUp).Row
K = 2
For j = 2 To 5
For i = 3 To N
v = Cells(i, j)
If v <> "" Then
Cells(K, "H") = Cells(i, "A")
Cells(K, "I") = v
Cells(K, "J") = Cells(2, j)
K = K + 1
End If
Next i
Next j
End Sub
will produce:
Upvotes: 1
Reputation: 59460
It is possibly with basically the process detailed here. However in your case you will need to switch the order of Column
and Value
in the resulting Table, Convert to Range to be able to sort on Row within Column and also filter to select and delete blank rows from Value
. Also you will need to change the column labels.
Upvotes: 0