+ Reply to Thread
Results 1 to 5 of 5

Find highest value in Column V for unique value in column R

  1. #1
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Question Find highest value in Column V for unique value in column R

    Small example of the columns:



    ABCD 1
    ABCD 1
    ABCD 2
    ABCD 0
    DCBA 0
    DCBA 1
    DCBA 1
    PPPP 0
    PPPP 1
    PPPP 2
    PPPP 2
    LLLL 0
    LLLL 0
    LLLL 1

    I need end up with the rows only with the highest number in the last column, so it should look like this after:

    ABCD 2
    DCBA 1
    DCBA 1
    PPPP 2
    PPPP 2
    LLLL 1


    I am sure this is some easy small code but I don't know where to start on this one really.... thanks!

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Find highest value in Column V for unique value in column R

    Are you sure you want all the other rows deleted??
    Gary's Student

  3. #3
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: Find highest value in Column V for unique value in column R

    Yes, I only want to keep (or extract to another page, but deleting the rows seems easier) the rows for each unique value in the first column with the highest number (all of the highest numbers not just one, as you see in the example there are many of the same highest number I need all of those rows now just one of them).

    It seems filtering wouldn't work for such a situation so I was looking at doing a quick macro but I'm not sure where to start.... doing it by hand would be ridiculous for me as there are around 20,000 rows on the sheet.

    Thanks!

    Quote Originally Posted by Jakobshavn View Post
    Are you sure you want all the other rows deleted??

  4. #4
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Exclamation Re: Find highest value in Column V for unique value in column R

    I am thinking it will have to be something like this, but I'm not sure of the functions availible for it... I don't really have any experience in VB, just Java / C++ and that is minimal.

    My two ideas for doing it would be:

    Create some sort of array (i know about these, dont really know how to work them though) that would create variable for each "unique value" from the first column.

    Then have the macro search every row and determine the highest value from the second column, say "2" or "3" or whatever.

    Then have the macro go through all the rows a second time and delete all rows for a given unique value that do not match the discovered highest value "2" or "3" or whatever.

    I know it should be possible, and not too difficult for an experienced VB writer, but I have no idea how to make this sort of array or whatever and where to start on this....

    Thanks!

  5. #5
    Registered User
    Join Date
    04-03-2013
    Location
    miami, florida
    MS-Off Ver
    Excel 2007
    Posts
    46

    Angry Re: Find highest value in Column V for unique value in column R

    Here is my attempt so far... but my brain hurts right now. There is one error saying "next without for statement" which makes no sense because I have that...

    The other problem is its not actually getting the highest replay per each unique value, it keeps reseting it to 0.

    The other HUGE problem, is this macro to run is going to loop 246924000000 times, which is just way to freaking slow, is there a way to make it so there are not these loops inside of loops or something?

    Thanks
    Please Login or Register  to view this content.

+ 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. Find 1st unique Value on Column and Insert certain Word on cell on left Column
    By Wldlife23 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-16-2013, 10:02 AM
  2. Replies: 1
    Last Post: 06-10-2013, 07:08 PM
  3. [SOLVED] Find three highest values on column A and print column B
    By diegodacal in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-18-2013, 04:05 PM
  4. [SOLVED] Need to find highest value in a column for each name in a separate column
    By audiofreak in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-21-2012, 12:26 PM
  5. Replies: 8
    Last Post: 08-20-2012, 01:27 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