+ Reply to Thread
Results 1 to 3 of 3

Large dataset sorting help

Hybrid View

  1. #1
    Registered User
    Join Date
    08-21-2014
    Location
    Baltimore, MD
    MS-Off Ver
    7
    Posts
    1

    Large dataset sorting help

    I would like to return a list of values that are attached to a similar string. For example, if my dataset looked like the following:

    A B
    100 Michael
    101 Michael
    102 Michael
    103 Michael
    104 Michael
    105 Michael
    110 James
    111 James
    112 James
    113 James
    230 Nicholas
    231 Nicholas
    232 Nicholas
    233 Nicholas
    234 Nicholas
    235 Nicholas


    I would like code that returns:

    A B
    Michael 100, 101, 102, 103, 104, 105
    James 110, 111, 112, 113
    Nicholas 230, 231, 232, 233, 234, 235



    As of now I can't figure out any formulas that would automate this process. Any help appreciated!

  2. #2
    Registered User
    Join Date
    08-19-2014
    Location
    Pittsburgh, Pennsylvania
    MS-Off Ver
    2010
    Posts
    45

    Re: Large dataset sorting help

    Try this:
    Sub kjibbsExample()
    Dim LR As Long
    Dim uLR As Long
    Dim shA As Worksheet
    Dim shO As Worksheet
    
    Set shA = ActiveSheet
    Worksheets.Add.Name = "Output"
    Set shO = Sheets("Output")
    
    LR = shA.Cells(Rows.Count, "A").End(xlUp).Row
    
    
    shA.Columns("B:B").Copy
    
    With shO
    .Columns("A:A").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    .Range("$A$1:$A$" & LR).RemoveDuplicates Columns:=1, Header:=xlYes
    End With
    
    uLR = shO.Cells(Rows.Count, "A").End(xlUp).Row
    
    Application.CutCopyMode = False
    For j = 2 To uLR
        For i = 2 To LR
            If shA.Range("b" & i).Value = shO.Range("A" & j).Value Then
            shO.Range("B" & j).Value = shO.Range("B" & j).Value & "," & shA.Range("a" & i).Value
            End If
        Next i
    Next j
    End Sub

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Large dataset sorting help

    or this
    Sub ertert()
    Dim x, i&
    x = Range("A1:B" & Cells(Rows.Count, 1).End(xlUp).Row).Value
    With CreateObject("Scripting.Dictionary")
        .CompareMode = 1
        For i = 1 To UBound(x)
            If .Exists(x(i, 2)) Then
                 .Item(x(i, 2)) = .Item(x(i, 2)) & ", " & x(i, 1)
            Else
                .Item(x(i, 2)) = x(i, 1)
            End If
        Next i
     Range("D1:E1").Resize(.Count).Value = Application.Transpose(Array(.keys, .items))
    End With
    End Sub

+ 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. Replies: 3
    Last Post: 01-23-2014, 10:13 AM
  2. [SOLVED] Graphing a large dataset
    By CTM2012 in forum Excel General
    Replies: 6
    Last Post: 06-18-2012, 03:48 PM
  3. Graphing a large dataset
    By CTM2012 in forum Excel General
    Replies: 9
    Last Post: 06-18-2012, 10:20 AM
  4. Array formulas for a large dataset
    By Freedan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2012, 12:48 PM
  5. Delete rows from a LARGE dataset
    By trillium in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2011, 05:50 PM

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