+ Reply to Thread
Results 1 to 12 of 12

List Unique Suppliers in Summary

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

    Cool List Unique Suppliers in Summary

    Hi there,

    Can someone give me a little advice please?

    I have a Data Sheet containing three columns that are important to me:

    • Element Code
    • Value
    • Supplier


    On the Summary Sheet I have a macro that takes just the unique Element Codes sums the corresponding Values. So for example the data sheet may read:

    CONS-001 $10 Internal
    CONS-001 $50 Smiths
    CONS-001 $10 Thompsons
    CONS-002 $20 Internal
    CONS-003 $10 Thompsons
    CONS-003 $10 Thompsons
    CONS-003 $15 Thompsons
    CONS-003 $10 Thompsons
    CONS-004 $15 Smiths
    CONS-004 $15 Internal

    And the summary sheet is automatically populated with:

    CONS-001 $70
    CONS-002 $20
    CONS-003 $45
    CONS-004 $30

    So that's all easy using a Advance Filter and then a SUMIF formula (in VBA).

    Now I need to add a 3rd column in that lists all of the suppliers that make up that total... i.e.

    CONS-001 $70 Internal, Smiths, Thompsons
    CONS-002 $20 Internal
    CONS-003 $45 Thompsons
    CONS-004 $30 Smiths, Thompsons

    Can you help at all please?

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: List Unique Suppliers in Summary

    Have you thought of using a Pivot Table.

    This performs the acts of filtering, summarising and analysing without going anywhere near functions or macros.

    If you've never used PTs I suggest you spend 1/2 an hour or so exploring them. You'll be pleasantly surprised at their simplicity once you understand what they're doing and you'll be able to analyse data in ways you've not even thought of yet.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

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

    Re: List Unique Suppliers in Summary

    HI there - yes, normally I use PTs for this task but I have so many of these to do I thought coding it would be better. Currently my spreadsheet imports the relevant data, formats it correctly and summarises it, before saving it using a standardized file name within a few seconds, a PT works, but is more time consuming when doing it hundreds of times.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: List Unique Suppliers in Summary

    Automate the PT with VBA?

  5. #5
    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.

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: List Unique Suppliers in Summary

    Hi,

    That's a slightly different requirement to your original request. I'm interpreting this to mean that you are automating with a looping procedure the import, process & saving of the file rather than doing this once as originally implied.

    Notwithstanding that I'm not clear why you think a PT is too time consuming. Refreshing a PT will be much quicker than any macro process to filter and summarise.

    Why not create a dynamic range name for the import area of your data and build a PT that uses that range name and just have an additional single line of code in your import macro code to refresh the PT before the Save part of your macro.

  7. #7
    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
    Please Login or Register  to view this content.
    Regards Mick

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

    Re: List Unique Suppliers in Summary

    Quote Originally Posted by Richard Buttrey View Post
    Hi,

    That's a slightly different requirement to your original request. I'm interpreting this to mean that you are automating with a looping procedure the import, process & saving of the file rather than doing this once as originally implied.

    Notwithstanding that I'm not clear why you think a PT is too time consuming. Refreshing a PT will be much quicker than any macro process to filter and summarise.

    Why not create a dynamic range name for the import area of your data and build a PT that uses that range name and just have an additional single line of code in your import macro code to refresh the PT before the Save part of your macro.
    Hi Richard, sorry I wasn't clear, I just wanted help with one small aspect of the project so I didn't detail the entirety. Apologies for any confusion, I'll have a look into your suggestion - but I haven't used dynamic range names before... nor have I used PTs from macros before. Hence I was going for the solution where I understand at least 90% of the solution.

    Thanks for the help.

  9. #9
    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!

  10. #10
    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 …

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

    Re: List Unique Suppliers in Summary



    I amended my previous post for a lighter code …

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

    Re: List Unique Suppliers in Summary


    To admin : I got a message : Sucuri WebSite Firewall - CloudProxy - Access Denied

    No way to post a new code whatever the tag code …

+ 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. 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