Compare values in 7 different cells, return description of the one with the highest value.

jaihawk8

Board Regular
Joined
Mar 23, 2018
Messages
58
Office Version
  1. 2016
Platform
  1. Windows
I have a spreadsheet, where I am trying to compare 7 different values (non-sequential) and return the description of the one with the highest value.

This is what I'm working with:

1611693353562.png


I'm trying to compare the values in F19, F30, F35, F36, K15, and K22. Which ever one has the highest value, I want it to return the description of that one. For instance, in this case, I would want it to return "Impress Distribute & Automate Subscription). If there is no higher value (i.e. they are all $0), then just return a blank space.

Is this doable?
 

Attachments

  • 1611693316711.png
    1611693316711.png
    67.1 KB · Views: 3

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
This isn't great. I used helper cells. I couldn't figure out how to create a disjoint range within a formula. (That's a question to ask here.)

all zeros will return blank. If there is a tie, the first one will be selected.

Cell Formulas
RangeFormula
P1P1=F19
Q1Q1=B19
R1R1=IF(MAX(P1:P6)>0,VLOOKUP(MAX(P1:P6),P1:Q6,2,FALSE),"")
P2P2=F30
Q2Q2=B30
P3:P4P3=F35
Q3:Q4Q3=B35
P5P5=K15
Q5Q5=H15
P6P6=K22
Q6Q6=H22
 
Upvote 0
I adapted a UDF from someone and made minor changes:

Code:
Function MatchNonContig(LookupVal As Variant, ParamArray LookupRng() As Variant)
    Dim i As Long, j As Long
    For i = 0 To UBound(LookupRng) - 1
        If LookupRng(i) = LookupVal Then
            j = i + 1
        End If
    Next i
    MatchNonContig = Choose(j, Range("A19"), Range("A30"), Range("A35"), Range("A36"), Range("H15"), Range("H22"))
End Function

Syntax would be:
Code:
=MatchNonContig(MAX(F19,F30,F35,F36,K15,K22),F19,F30,F35,F36,K15,K22)
 
Upvote 0
GROAN...I found a problem with the UDF...checking it again.
 
Upvote 0
Think I found the issue:

Code:
Function MatchNonContig(LookupVal As Variant, ParamArray LookupRng() As Variant)
    Dim i As Long, j As Long
    j = 0
    For i = 0 To UBound(LookupRng)
        If LookupRng(i) = LookupVal Then
          j = i + 1
        End If
    Next i
          MatchNonContig = Choose(j, Range("A19"), Range("A30"), Range("A35"), Range("A36"), Range("H15"), Range("H22"))
    
End Function
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top