+ Reply to Thread
Results 1 to 12 of 12

List Unique Suppliers in Summary

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-27-2006
    Location
    Cayman Islands
    Posts
    379

    Re: List Unique Suppliers in Summary

    Hmmm, OK maybe I'll give that a try.

    To be honest from an output perspective the current methodology gives the ideal result. But if it's that difficult I'll look for another solution.

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

    Re: List Unique Suppliers in Summary

    Try this :-
    Results sheet2 from Data on sheet1
    Sub MG05May43
    Dim Rng As Range, Dn As Range, n As Long, c As Long
    Dim Q As Variant
    With Sheets("Sheet1")
        Set Rng = .Range(.Range("A1"), .Range("A" & Rows.Count).End(xlUp))
    End With
        ReDim Ray(1 To Rng.Count, 1 To 3)
        Ray(1, 1) = "Item Code": Ray(1, 2) = "Total": Ray(1, 3) = "Name"
        n = 1
    
    With CreateObject("scripting.dictionary")
        .CompareMode = vbTextCompare
    For Each Dn In Rng
        If Not .Exists(Dn.Value) Then
            n = n + 1
            Ray(n, 1) = Dn.Value: Ray(n, 2) = Dn.Offset(, 1).Value
            Ray(n, 3) = Dn.Offset(, 2).Value
            .Add Dn.Value, Array(n, 3, Dn.Offset(, 2).Value)
        Else
            Q = .Item(Dn.Value)
                Ray(Q(0), 2) = Ray(Q(0), 2) + Dn.Offset(, 1).Value
                If InStr(Q(2), Dn.Offset(, 2).Value) = 0 Then
                        Q(1) = Q(1) + 1
                        If UBound(Ray, 2) < Q(1) Then ReDim Preserve Ray(1 To Rng.Count, 1 To Q(1))
                    Ray(Q(0), Q(1)) = Dn.Offset(, 2).Value
                    Ray(1, Q(1)) = "Name"
                End If
            .Item(Dn.Value) = Q
       End If
    Next
    c = .Count
    End With
    
    With Sheets("Sheet2").Range("A1").Resize(c + 1, UBound(Ray, 2))
         .Value = Ray
        .Columns.AutoFit
    End With
    MsgBox "Run"
    End Sub
    Regards Mick

  3. #3
    Forum Contributor
    Join Date
    04-27-2006
    Location
    Cayman Islands
    Posts
    379

    Re: List Unique Suppliers in Summary

    Thanks MickG - I'll give that a go!

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Re: List Unique Suppliers in Summary



    Hi !

    First idea is to still use an advanced filter but you already have a code …

    So try this demonstration using an array variable as a dictionary (Data row #1 is columns titles) :

    PHP Code: 
    Sub Demo1()
         Const 
    DATA "Data"SR ", "
                              
    VA Worksheets(DATA).Cells(1).CurrentRegion
        ReDim DK
    $(1 To UBound(VA), 0), DS(1 To UBound(VA), 1 To 2)

        For 
    R& = 2 To UBound(VA)
                       
    Application.Match(VA(R1), DK0)
            If 
    IsError(VThen
                L
    & = L& + 1:  DK(L0) = VA(R1):  DS(L1) = VA(R2):  DS(L2) = VA(R3)
            Else
                
    DS(V1) = DS(V1) + VA(R2)
                If 
    InStr(SR DS(V2) & SRSR VA(R3) & SR) = 0 Then DS(V2) = DS(V2) & SR VA(R3)
            
    End If
        
    Next

        With Worksheets
    ("Summary")
            .
    UsedRange.Clear
            Worksheets
    (DATA).[A1:C1].Copy .Cells(1)

            
    With .[A2].Resize(L3)
                 .
    Columns(1).Value DK
                 Worksheets
    (DATA).[B2].Copy:  .Columns(2).PasteSpecial xlPasteFormats
                 
    .Columns("B:C").Value DS
                 
    .Columns(3).AutoFit
            End With

            Application
    .CutCopyMode False:  Application.Goto .Cells(5)
        
    End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 05-06-2015 at 04:44 AM. Reason: optimizing …

+ 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: 10-10-2014, 03:55 AM
  2. Count of unique items after Autofilter to another summary sheet
    By Kiran2012 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2014, 07:21 AM
  3. [SOLVED] Summary for unique ProductID and Total Quantity
    By maniootek in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 01-26-2014, 09:10 PM
  4. Populate shirt costs from suppliers price list?
    By malform in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2010, 04:25 PM
  5. [SOLVED] summary count of unique numbers
    By Dave Edge in forum Excel General
    Replies: 5
    Last Post: 11-11-2005, 08:10 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