# Lookup a value and then find the largest in a range

#### fazthfc

##### New Member
Hi,

I have a set of data that looks like this:

 Name 1 2 3 4 5 A 12 15 16 10 6 B 6 4 15 1 19 C 22 14 13 17 10 D 6 8 7 10 6 E 8 9 15 26 4 F 10 14 19 2 10 G 15 16 20 25 15 H 16 20 22 10 8 I 14 16 19 17 6

<tbody>
</tbody>

In another sheet I have the list of names but not in the same order (there is a reason for that). I want a formula that will look for the Name in column A and then return the largest number for that name in columns B:F.

For example:

Forumula looks at the name sees E and returns 26.

I've tried looking at HLOOKUP, MATCH and INDEX but can't find a way of looking at the range based on a specific criteria.

Any help greatly appreciated.

### Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

#### Kamolga

##### Well-known Member
Hi,

I use the max formula on a line and set up the number of line with a match in the column. Indirect put them together.

Code:
``=MAX(INDIRECT("Sheet1!\$B\$"&MATCH(Sheet2!A2;Sheet1!\$A\$1:\$A\$10)&":\$F\$"&MATCH(Sheet2!A2;Sheet1!\$A\$1:\$A\$10)))``
I can go in more details if it does not work for you

#### RasGhul

##### Well-known Member
Hi faz,

Maybe this;

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">Name</td><td style="text-align: right;;">1</td><td style="text-align: right;;">2</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">A</td><td style="text-align: right;;">12</td><td style="text-align: right;;">15</td><td style="text-align: right;;">16</td><td style="text-align: right;;">10</td><td style="text-align: right;;">6</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">B</td><td style="text-align: right;;">6</td><td style="text-align: right;;">4</td><td style="text-align: right;;">15</td><td style="text-align: right;;">1</td><td style="text-align: right;;">19</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">C</td><td style="text-align: right;;">22</td><td style="text-align: right;;">14</td><td style="text-align: right;;">13</td><td style="text-align: right;;">17</td><td style="text-align: right;;">10</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">D</td><td style="text-align: right;;">6</td><td style="text-align: right;;">8</td><td style="text-align: right;;">7</td><td style="text-align: right;;">10</td><td style="text-align: right;;">6</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">E</td><td style="text-align: right;;">8</td><td style="text-align: right;;">9</td><td style="text-align: right;;">15</td><td style="text-align: right;;">26</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style=";">F</td><td style="text-align: right;;">10</td><td style="text-align: right;;">14</td><td style="text-align: right;;">19</td><td style="text-align: right;;">2</td><td style="text-align: right;;">10</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style=";">G</td><td style="text-align: right;;">15</td><td style="text-align: right;;">16</td><td style="text-align: right;;">20</td><td style="text-align: right;;">25</td><td style="text-align: right;;">15</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style=";">H</td><td style="text-align: right;;">16</td><td style="text-align: right;;">20</td><td style="text-align: right;;">22</td><td style="text-align: right;;">10</td><td style="text-align: right;;">8</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style=";">I</td><td style="text-align: right;;">14</td><td style="text-align: right;;">16</td><td style="text-align: right;;">19</td><td style="text-align: right;;">17</td><td style="text-align: right;;">6</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br />

<b>Note: Do not try and enter the {} manually yourself</b></td></tr></table><br />

#### James006

##### Well-known Member
Hello,

With your Table in Sheet1 ... and your formula in Sheet2 ...

Cell A2 : B

Cell B2 :
Code:
``=MAX(OFFSET(Sheet1!\$A\$1,MATCH(A2,Sheet1!\$A\$2:\$A\$10,0),1):OFFSET(Sheet1!\$A\$1,MATCH(A2,Sheet1!\$A\$2:\$A\$10,0),5))``
Hope this will help

#### Fluff

##### MrExcel MVP, Moderator
Another option

<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">Name</td><td style="text-align: right;;">1</td><td style="text-align: right;;">2</td><td style="text-align: right;;">3</td><td style="text-align: right;;">4</td><td style="text-align: right;;">5</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">A</td><td style="text-align: right;;">12</td><td style="text-align: right;;">15</td><td style="text-align: right;;">16</td><td style="text-align: right;;">10</td><td style="text-align: right;;">6</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style=";">B</td><td style="text-align: right;;">6</td><td style="text-align: right;;">4</td><td style="text-align: right;;">15</td><td style="text-align: right;;">1</td><td style="text-align: right;;">19</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">4</td><td style=";">C</td><td style="text-align: right;;">22</td><td style="text-align: right;;">14</td><td style="text-align: right;;">13</td><td style="text-align: right;;">17</td><td style="text-align: right;;">10</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">5</td><td style=";">D</td><td style="text-align: right;;">6</td><td style="text-align: right;;">8</td><td style="text-align: right;;">7</td><td style="text-align: right;;">10</td><td style="text-align: right;;">6</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">6</td><td style=";">E</td><td style="text-align: right;;">8</td><td style="text-align: right;;">9</td><td style="text-align: right;;">15</td><td style="text-align: right;;">26</td><td style="text-align: right;;">4</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">7</td><td style=";">F</td><td style="text-align: right;;">10</td><td style="text-align: right;;">14</td><td style="text-align: right;;">19</td><td style="text-align: right;;">2</td><td style="text-align: right;;">10</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">8</td><td style=";">G</td><td style="text-align: right;;">15</td><td style="text-align: right;;">16</td><td style="text-align: right;;">20</td><td style="text-align: right;;">25</td><td style="text-align: right;;">15</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">9</td><td style=";">H</td><td style="text-align: right;;">16</td><td style="text-align: right;;">20</td><td style="text-align: right;;">22</td><td style="text-align: right;;">10</td><td style="text-align: right;;">8</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">10</td><td style=";">I</td><td style="text-align: right;;">14</td><td style="text-align: right;;">16</td><td style="text-align: right;;">19</td><td style="text-align: right;;">17</td><td style="text-align: right;;">6</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p><br /><br />

1,102,150
Messages
5,485,048
Members
407,479
Latest member
jbone2020

### This Week's Hot Topics

• Finding issue in If elseif else with For each Loop
Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
• MsgBox Error
Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
• CELL FORMAT - IF CONDITION
My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
• Show numbers nearly the same
Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...