+ Reply to Thread
Results 1 to 9 of 9

Thread: Listing the Highest Common Value in a Table

  1. #1
    Registered User
    Join Date
    07-05-2005
    Posts
    25

    Question Listing the Highest Common Value in a Table

    I used to fancy myself quite the Excel adept until I ran into this problem. 90 minutes later and I'm no closer to solving it. What I am trying to do is simply compare the numerical values of multiple columns in a table and find the highest value number that occurs in all columns. It's basically a cross between GCD() or MAX() and MATCH() but I need it to work in an array/index fashion and the number has to be present in every column of the table. For example:

         A     B     C     D     E
    1    2     4     12    20    1
    2    3     8     15    24    4
    3    4     12    18    28    9
    4    6     16    21    32    14
    5    24    18    24    36    19
    6    36    24    27    40    24
    So, out of that example, I need to get "24" as a result as it occurs in every column, and where it occurs row-wise isn't a concern at this point.

    Thanks in advance for reading!

  2. #2
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,151

    Re: Listing the Highest Common Value in a Table

    Hello,

    do you need one formula or would you be happy with helper cells?

    Also, is it conceivable that the number does not occur in every column? If it is guaranteed to occur in each column, then the smallest number of each column maximum is the number you are after.

    You can set up helper cells with

    =MAX(A1:A6)

    copied across, then take the MIN() of these results. Or, in one formula

    =MIN(MAX(A1:A6),MAX(B1:B6),MAX(C1:C6),MAX(D1:D6),MAX(E1:E6))

    cheers,

  3. #3
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,285

    Re: Listing the Highest Common Value in a Table

    Hi centerNegative,

    With many helping columns I have a solution. See the attached. I really want to see what teylyn comes up with.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  4. #4
    Registered User
    Join Date
    07-05-2005
    Posts
    25

    Re: Listing the Highest Common Value in a Table

    Thanks for the quick reply, teylyn. Unfortunately, that doesn't accomplish what I need. When I evaluate that formula, I see that what it's doing is only finding the lowest value of the maximum values from each column, and the formula evaluates out to MIN(36,24,27,40,24). That example was probably poor but the data with which I'm dealing is too large to post here. I'll try and simplify what it is.

    I have a table that's setup to find the largest common number between 1 and 1200 that is divisible evenly (i.e., whole integers) by 2, 3, 4, 5, 6, 8, and 10, excluding 1200 itself. So, I have seven columns headed by each of those numbers, and then I have an index column, numbered 1 through 600 to cover the full spread of multiples up to 1200. The solution is 1080, which is present in all seven factor columns, however the above formula results in 1180, which makes sense based on how it works, so it just isn't what I am looking for.

    As I said, it seems to me to really be a cross between the MAX() function and the GCD() function that I'm looking for but I can't wrap my brain out for the time being. Maybe I can try chaining GCD() functions instead of MAX() functions...

    Thanks very much for assisting! I hope the explanation of my issue make sense.

  5. #5
    Forum Guru
    Join Date
    10-28-2008
    Location
    Not here anymore
    MS-Off Ver
    irrelevant
    Posts
    10,151

    Re: Listing the Highest Common Value in a Table

    Marvin's approach should work for you, then.

  6. #6
    Registered User
    Join Date
    07-05-2005
    Posts
    25

    Re: Listing the Highest Common Value in a Table

    Ack, totally missed your post, Marvin. That definitely does the trick. Is there possibly a way to condense all that into single formula using SUMPRODUCT() for the logical tests?

  7. #7
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,285

    Re: Listing the Highest Common Value in a Table

    Hey - I felt happy getting any answer at all after you spent an hour and a half thinking about it.

    DonkeyOte or Teylyn are the real guru's to compress it into a sumproduct or array formula.

    I could write a User Defined Function to find the value easier than understanding what the real gurus develop.
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  8. #8
    Registered User
    Join Date
    07-05-2005
    Posts
    25

    Re: Listing the Highest Common Value in a Table

    Hahahaa, fair enough. I'll tinker around with it a bit. My main concern is that this is something I will use in the future for varying value ranges and table sizes and setting up a large helper table just seems less flexible to me but, you're right, it gets the job done.

  9. #9
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Listing the Highest Common Value in a Table

    If as implied the numbers in each column are unique then see below (note array entry required)

    =MAX(IF(ISNUMBER($A$1:$A$6),IF(COUNTIF($B$1:$E$6,$A$1:$A$6)=COLUMNS($B$1:$E$6),$A$1:$A$6)))
    confirmed with CTRL + SHIFT + ENTER (enter alone will not suffice)
    the above simply applies a COUNTIF to each value in first column to see if result matches the column count - where it does the number is valid - the max of the valid numbers is then returned.
    Last edited by DonkeyOte; 01-07-2011 at 03:34 AM. Reason: clarified final sentence

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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