Results 1 to 4 of 4

Thread: Finding multiples of unique values

  1. #1
    New Member
    Join Date
    Jun 12
    Posts
    12

    Finding multiples of unique values

    I don't think this problem is too complex but the logic's confusing me at the moment and a few heads might be better than one.

    In column A I have a list of document filenames which relate to the product they represent. These come from a number of different sources, which are listed in column B. So if I've taken a document for product X from source Y, column A will contain an X and B a Y for that row.

    Some of these product names are duplicated, so I've created a macro which trims the list in A into a list of unique product names in column C. Some of these are duplicated because there is a similar document from multiple sources but I'm interested in the ones which are duplicated in the same source.

    So I'm looking at the unique product in column C, looking back to the original data in column A which may have multiple references to that unique product. Then I want to look across from those cells at column B and check if the values in there are the same. If they are then I want to put an indicator in a new column relating to each source.

    Currently I'm trying to code something in VBA (I'd be open to a spreadsheet solution) and can lookup and find references to the corresponding cells in A but I'm unsure how I can compare the values in these references as I'm struggling to find them simultaneously.

  2. #2
    Fanatic Member
    Join Date
    Oct 08
    Location
    Midwest Region, United States
    Posts
    1,010

    Re: Finding multiples of unique values

    Could you mock up a small example of what the data looks like (I think I'm clear on that part), and what you want the "output" to be (not so clear on that)?

  3. #3
    New Member
    Join Date
    Jun 12
    Posts
    12

    Re: Finding multiples of unique values

    Fruit Country Unique Fruit Spain Greece Italy France Chile Australia
    Orange Spain Orange 1 0 0 0 0 0
    Orange Spain Grape 0 0 0 1 0 1
    Orange Spain
    Orange Greece
    Orange Italy
    Grape France
    Grape France
    Grape Chile
    Grape Australia
    Grape Australia

    OK, suppose I'm buying fruit and have different suppliers in different countries. I want to know when I have multiple suppliers from one country, indicated by a 1, and when that isn't an issue; 0.

  4. #4
    New Member
    Join Date
    Jun 12
    Posts
    12

    Re: Finding multiples of unique values

    I've now got something which can cover my needs and possibly help more, by listing all the sources to the right of the unique device. I'll use conditional formatting or something to highlight the duplicates Here's my code for those interested and I'll leave the thread open for the time being if people would like to try and tweak it to correspond to my initial request.

    Code:
    Sub FindLocations()
    
        Application.ScreenUpdating = False
        Z = Range("C3").End(xlDown).Row
        Y = Range("A3").End(xlDown).Row
        For i = 3 To Z
            Cells(i, 3).Select
            N = WorksheetFunction.CountIf(Range("A:A"), Cells(i, 3))
            Start = 3
            For j = 1 To N
                Cells(i, 3 + j) = Range(Cells(Start, 1), Cells(Y, 1)).Find(Cells(i, 3).Value).Offset(0, 1)
                Start = Range(Cells(Start, 1), Cells(Y, 1)).Find(Cells(i, 3).Value).Row
            Next j
        Next i
    
    End Sub

Posting Permissions

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