Converting Data to Filterable format.

awat17

New Member
Joined
Sep 28, 2017
Messages
1
I have a spreadsheet that is not in a usable format and need help rearranging it.

It is currently formatted like the table below but with over 300 Kids and 20 clubs. This format has a lot of empty cells and its not easy to filter.

NameClub1Club2Club3Club4Club5
Kid1Choice 1Choice2
Kid2Choice 1Choice2
Kid3Choice 2Choice 1
Kid4Choice 2Choice 1

<tbody>
</tbody>


I would like my table to look like this:
NameChoice 1Choice 2Choice 3
Kid 1Club 1Club 2Club3
Kid 2Club 4Club 6Club 1
Kid 3Club 8Club 2Club 7
Kid 4Club 1Club 3Club 8

<tbody>
</tbody>


Any help would be appreciated.

Thanks!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Assuming Current Format is in Sheet1 from cells A1 to U 301 i.e. 300 Kids and 20 clubs

And you create the new format in a New Sheet starting from A1 with Choices in first row and kid names in first column.

Enter this formula in cell B2 in new sheet and drag to get the club names

=IFERROR(INDEX(Sheet1!$B$1:$U$1,,MATCH(B$1,OFFSET(Sheet1!$B$1:$U$1,MATCH($A2,Sheet1!$A$2:$A$301,0),,),0)),"")
 
Upvote 0
Welcome to the MrExcel board!

Your sample result doesn't seem to relate to your sample data, and you didn't say where you wanted the results, but see if this macro helps.
It puts the results off to the right of the original data.
Test in a copy of your workbook.

Code:
Sub Rearrange()
  Dim d As Object
  Dim a As Variant, b As Variant
  Dim i As Long, j As Long
  Dim s As String
  
  Set d = CreateObject("Scripting.Dictionary")
  d.CompareMode = 1
  d(0) = Empty
  With Range("A1").CurrentRegion
    a = .Value
    ReDim b(1 To UBound(a), 1 To 1)
    b(1, 1) = a(1, 1)
    For i = 2 To UBound(a, 1)
      b(i, 1) = a(i, 1)
      For j = 2 To UBound(a, 2)
        s = a(i, j)
        If Len(s) > 0 Then
          If Not d.exists(s) Then
            d(s) = d.Count + 1
            ReDim Preserve b(1 To UBound(b), 1 To d.Count)
            b(1, d.Count) = s
          End If
          b(i, d(s)) = a(1, j)
        End If
      Next j
    Next i
    .Offset(, .Columns.Count + 1).Resize(UBound(b, 1), UBound(b, 2)).Value = b
  End With
End Sub

The code above produced the results shown in columns H:J from the original data shown in A:F.


Book1
ABCDEFGHIJ
1NameClub1Club2Club3Club4Club5NameChoice 1Choice 2
2Kid1Choice 1Choice 2Kid1Club2Club4
3Kid2Choice 1Choice 2Kid2Club1Club3
4Kid3Choice 2Choice 1Kid3Club2Club1
5Kid4Choice 2Choice 1Kid4Club5Club3
Rearrange
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,796
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top