# MS Excel - is there a way to do this?

**URL:** https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256
**Category:** Factual Questions
**Created:** [December 17, 2004, 2:40am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256 "2004-12-17T02:40:32Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![aerodave](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@aerodave](https://boards.straightdope.com/u/aerodave)
#### Post date: [December 17, 2004, 2:40am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/1 "2004-12-17T02:40:32Z")

</div>

Sorry for the vague title…I couldn’t think of a way to sum up the question in a few words.

Let’s say that in Excel, I have two columns as shown:

```auto

Homer 3
Marge 4
Bart 2
Lisa 6
Maggie 5

```

I want another cell in the sheet to display the name of the person with the biggest number. Using the MAX function will only return the greatest value in the column, and the resulting cell would read “6”. Instead, I want to have a cell that says “Lisa”.

If I could just get a function to return the cell reference of the greatest value, instead of the value itself, I could use OFFSET to cause it to return the row heading. But I don’t know anything that does this. Or maybe that’s not how I want to do this. Is there a better way?

---

<div class="post-metadata">

### Author: ![Aural\_Sects](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@Aural\_Sects](https://boards.straightdope.com/u/Aural_Sects)
#### Post date: [December 17, 2004, 3:21am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/2 "2004-12-17T03:21:13Z")

</div>

It could be done with an if then formula but would be a long ass one. how many entries would you have?

---

<div class="post-metadata">

### Author: ![Shagnasty](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Shagnasty](https://boards.straightdope.com/u/Shagnasty)
#### Post date: [December 17, 2004, 3:21am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/3 "2004-12-17T03:21:20Z")

</div>

Are you commited to using Excel? I could try to come up with some very convoluted way to do this in Excel but MS Access is really the tool for this type of thing. Accomplishing this task in Access is pretty trivial.

---

<div class="post-metadata">

### Author: ![aerodave](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@aerodave](https://boards.straightdope.com/u/aerodave)
#### Post date: [December 17, 2004, 3:57am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/4 "2004-12-17T03:57:29Z")

</div>

Let’s just say it would be most convenient to use Excel. If it proves to be mostly impossible, I’ll try with Access.

---

<div class="post-metadata">

### Author: ![Athena](https://avatars.discourse-cdn.com/v4/letter/a/35a633/32.png) [@Athena](https://boards.straightdope.com/u/Athena)
#### Post date: [December 17, 2004, 3:59am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/5 "2004-12-17T03:59:04Z")

</div>

You need the LOOKUP function.

If your sheet starts in cell A1, the formula you’re looking for is:

LOOKUP(MAX(B1:B5), B1:B5, A1:A5)

---

<div class="post-metadata">

### Author: ![aerodave](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@aerodave](https://boards.straightdope.com/u/aerodave)
#### Post date: [December 17, 2004, 4:23am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/6 "2004-12-17T04:23:16Z")

</div>

Well, I’ll be damned.

That does it! Thanks so much!

---

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [December 17, 2004, 4:30am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/7 "2004-12-17T04:30:47Z")

</div>

Lookup will not work. You need the values in order for LOOKUP to work.

From help:

> [@](#):
>
> **Important** The values in lookup\_vector must be placed in ascending order: …,-2, -1, 0, 1, 2, …, A-Z, FALSE, TRUE; otherwise, LOOKUP may not give the correct value. Uppercase and lowercase text are equivalent.

---

<div class="post-metadata">

### Author: ![aerodave](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@aerodave](https://boards.straightdope.com/u/aerodave)
#### Post date: [December 17, 2004, 4:41am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/8 "2004-12-17T04:41:57Z")

</div>

Well, I just figured that out, as well. Weird thing is, it only faisl some of the time when the vector is out of order.

But I can use the MATCH function, and give it \*match\_type \* 0, so that it will use any order. Using the returned position in the array and the OFFSET function, I can reference the right cell.

---

<div class="post-metadata">

### Author: ![erislover](https://avatars.discourse-cdn.com/v4/letter/e/71e660/32.png) [@erislover](https://boards.straightdope.com/u/erislover)
#### Post date: [December 17, 2004, 4:50am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/9 "2004-12-17T04:50:19Z")

</div>

I came up with this, for column A having the text you want, and column B having the numbers, using INDIRECT and MATCH  
=INDIRECT(ADDRESS(MATCH(MAX(B1:B7),B1:B7,0),1))

---

<div class="post-metadata">

### Author: ![dorfl](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@dorfl](https://boards.straightdope.com/u/dorfl)
#### Post date: [December 17, 2004, 8:32am UTC](https://boards.straightdope.com/t/ms-excel-is-there-a-way-to-do-this/280256/10 "2004-12-17T08:32:35Z")

</div>

> [@erislover](#):
>
> I came up with this, for column A having the text you want, and column B having the numbers, using INDIRECT and MATCH  
> =INDIRECT(ADDRESS(MATCH(MAX(B1:B7),B1:B7,0),1))

I like index better since it shows the range more explicitely

= index(a1:a7,match(max(b1:b7),b1:b7,false),0)

Dorfl
