Thread: Index Formula
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bernard Liengme[_3_] Bernard Liengme[_3_] is offline
external usenet poster
 
Posts: 1,104
Default Index Formula

Here is a UDF that will do the job.
With the data you have, call it on row 2 with =SupMax(B2:D2) to get "Sup 2
Sup 3"

Function SupMax(myrange)
suprow = 1 'This is the row with supplier names
supcol = myrange(1).Column - 1
maxcost = WorksheetFunction.Max(myrange)
For j = 1 To myrange.Count
If myrange(j) = maxcost Then
TempSup = TempSup & Cells(suprow, j + supcol) & " "
End If
Next j
SupMax = TempSup
End Function


New to VBA? Then try these sites
David McRitchie's site on "getting started" with VBA
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Debra Dalgleish's "Adding Code to a Workbook"
http://www.contextures.com:80/xlvba01.html

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email


"Cow Girl" wrote in message
...
Eduardo - I could not get your formula to work. I'm not sure what I'm
doing
wrong.

Bernard - Your formula worked, although I failed to mention that my
spreadsheet actually has about 50 suppliers, so I'm not sure if I could
expand your IF statement out that far. I know that was my bad. Sorry.

Any new ideas?

Thanks,
Cathy


"Cow Girl" wrote:

I need some help and haven't had luck searching for it on here. I have a
large spreadsheet that has location info in column A. The rest of the
columns
contain the pricing for each location by supplier. My table looks like
this:


Sup 1 Sup 2 Sup 3
PIT 5.50 6.00 6.00
LAX 5.50 5.50 4.50
ORD 6.00 5.25 5.50

In Column E, I'd like the max value, and in Column F, the Supplier
Name(s)
with the max value for each location.

I'm good with Column E (=MAX(B2:D2)), and getting "6", but I'm stuck on
Column F.

I found this formula: =INDEX($B$1:$D$1,MATCH(MAX($B2:$D2),$B2:$D2,0)),
but
it's only returning "Sup 2" where I'd like to see both Sup 2 & Sup 3. I
have
no problems listing each supplier in a different column, but when I drag
it
over to Column G, I still only get Sup 2.

All help is greatly appreciated!!!