+ Reply to Thread
Results 1 to 2 of 2

Identify mins in array for each unique key and return to new worksheet

  1. #1
    Registered User
    Join Date
    07-09-2009
    Location
    Austin, Texas
    MS-Off Ver
    Excel 2000
    Posts
    1

    Identify mins in array for each unique key and return to new worksheet

    Sorry - first post ever. Here is what I'm trying to do:

    Spreadsheet Structure:
    Column A Column B Column C
    111111 12345 0.25
    111111 23456 0.33
    111111 34567 0.21
    222222 23564 0.11
    333333 34564 0.37
    333333 23546 0.44
    444444 12345 0.71

    Requirement:
    Don't care if this uses functions or VBA. I need something to go through the spreadsheet, and for each unique value in column A, return the MIN value in column C and the associated value for column B into a new worksheet along with the value from Column A. So in the structure above, the output of the code would be, in a new worksheet:

    Column A Column B Column C
    111111 34567 0.21
    222222 23564 0.11
    333333 34564 0.37
    444444 12345 0.71

    One more observation - the actual data set is much larger - several thousand rows. There could be anywhere from one to 100 similar values in column A. Not sure this matters but thought I would mention.

    Any ideas would be greatly appreciated.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Identify mins in array for each unique key and return to new worksheet

    Hi agabbi, welcome to the forum. Due to the size of the data, I would recommend and "on-demand" macro.

    Here's a macro that will create a sheet called "MinReport" and put your values in it.
    Please Login or Register  to view this content.
    How to use the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save your sheet

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    Last edited by JBeaucaire; 07-09-2009 at 02:25 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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