+ Reply to Thread
Results 1 to 6 of 6

Transform list into summary

Hybrid View

  1. #1
    Registered User
    Join Date
    09-15-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    56

    Transform list into summary

    Fruit Owner
    Apple Jack
    Apple Jack
    Apple Jack
    Apple Peter
    Apple Peter
    Orange Jack
    Orange Peter
    Orange Jack
    Orange Peter
    Grape Jack
    Grape Jack
    Grape Jack
    Grape Peter

    list with 2 columns, transforming into these 2 groups (top for Jack and bottom for Peter)

    Apple 3
    Orange 2
    Grape 3

    Apple 2
    Orange 2
    Grape 1

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Transform list into summary

    Try this:-
    Results start "E1"
    Sub MG28Oct35
    Dim Dn As Range, k As Variant
    Dim p As Variant, c As Long
    Dim Rng As Range, Dic As Object
    
    Set Rng = Range(Range("B2"), Range("B" & Rows.Count).End(xlUp))
     Set Dic = CreateObject("Scripting.Dictionary")
        Dic.CompareMode = 1
       For Each Dn In Rng
                If Not Dic.exists(Dn.Value) Then
                    Set Dic(Dn.Value) = CreateObject("Scripting.Dictionary")
                End If
            
            If Not Dic(Dn.Value).exists(Dn.Offset(, -1).Value) Then
                 Dic(Dn.Value).Add (Dn.Offset(, -1).Value), 1
            Else
                Dic(Dn.Value).Item(Dn.Offset(, -1).Value) = _
                Dic(Dn.Value).Item(Dn.Offset(, -1).Value) + 1
            End If
        Next Dn
       
    For Each k In Dic.Keys
            c = c + 1
            Cells(c, "E") = k
                For Each p In Dic(k)
                   c = c + 1
                    Cells(c, "F") = p
                    Cells(c, "G") = Dic(k).Item(p)
                Next p
            Next k
    End Sub
    Regards Mick

  3. #3
    Registered User
    Join Date
    09-15-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Transform list into summary

    Hey Mick,

    some next level stuff here, it looks perfect.

    thanks heaps!

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Transform list into summary

    Why not just go with Pivot Table
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    09-15-2013
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    56

    Re: Transform list into summary

    true, pivot table would definitely be more convenient.

    But I was quite curious on how can this be done with macro and the procedure which MickG has done up has stuff that I have never come across before.

    something to pick up here.

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Transform list into summary

    You're welcome

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Extracting summary list of larger list showing only items that have quantities
    By BenjaminRCP in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-14-2014, 01:01 PM
  2. [SOLVED] Summary list
    By peri1224 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-13-2012, 11:08 AM
  3. Summary for list
    By sureshp.rpt in forum Excel General
    Replies: 4
    Last Post: 06-24-2010, 07:27 AM
  4. How to transform list
    By azharinor in forum Excel General
    Replies: 2
    Last Post: 02-26-2008, 02:48 AM
  5. Pulling a Summary List from a Larger List
    By Stephen - Dallas in forum Excel General
    Replies: 2
    Last Post: 05-03-2006, 09:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1