+ Reply to Thread
Results 1 to 3 of 3

Selectively Picking Duplicates

Hybrid View

  1. #1
    Registered User
    Join Date
    07-16-2008
    Location
    CT
    Posts
    1

    Selectively Picking Duplicates

    I'm trying to get Excel to do a certain function, I'm not sure if it can be done with normal functions/formulas or if it requires programming. But basically, here's what I need to do:

    There are several B column coordinates that I want paired up with A column coordinates. For example, column B has 4 duplicate entries of 40, and column A has 1000, 1010, 1020 and 1030. I want Excel to selectively choose only the row that contains 40, 1000. Then let's say the next 8 rows are all 41 in column B, and column A has entries of 1005 (we'll just say 1005 is the lowest number), 1006, 1092, etc. and so on. Again, I want Excel to selectively choose only the row that contains 41, 1005. The farthest I've gotten is sorting the columns in ascending order so I can visually see the coordinates, but is there a way to get rid of all the other duplicates (such as 40, 1010 and 40, 1020, etc.) so that my final spreadsheet will have no duplicates in column B? I would do it manually but there are over 400 numbers each with a varying number of duplicates (ie: I have four duplicates of the value 40, ten duplicates of the value 41, etc.) paired up with numbers in column A. I was wondering if that was a function that could automatically pick the lowest number in column A associated with each different number in column B.

    I hope that was clear enough, but I can try to be more specific if need be.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try this macro

    Sub Test()
    For N = 1 To Cells(65536, 1).End(xlUp).Row
        If N = 1 Then
            Cells(65536, 4).End(xlUp).Offset(1, 0) = Cells(N, 1)
            Cells(65536, 4).End(xlUp).Offset(0, 1) = Cells(N, 2)
        ElseIf Cells(N, 2) <> Cells(N - 1, 2) Then
            Cells(65536, 4).End(xlUp).Offset(1, 0) = Cells(N, 1)
            Cells(65536, 4).End(xlUp).Offset(0, 1) = Cells(N, 2)
        End If
    Next N
    End Sub

    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007.

  3. #3
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    one option

    This is one alternative (see encl. file):

    In column C:
    =MIN(IF((B4=$B$4:$B$16)*($A$4:$A$16)=0;FALSE;$A$4:$A$16))=A4
    Then use Autofilter to find all the lowest numbers marked True

    Hope it helped
    //Ola


    Note: the formula must be Array Entered (read the blue text) to work.
    Attached Files Attached Files
    Last edited by olasa; 07-16-2008 at 03:16 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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