1

I'm not sure if I'm over complicating this... basically I'd like to have a formula which is if the c column is less than 6, then look up the max value in B but display the value of C

so far I have this but I'd like it to show 2, not 437

{=MAX(IF(C2:C12<6,B2:B12, 0))}

any advice is appreciated. i'm shy, be nice..thanks

A       B       C 
cat     110     3
dog     148     4
rooster  36     7
duck     32     8
pig     437     2
horse    44     6
eagle   215     5
dolphin  21     1
panda     2     9
iguana  257    10
fish    199    11

edit:

maybe something like {=INDEX(C2:C12,MATCH(MAX(IF(C2:C12<6,C2:C12)),C2:C12,0))}

but I don't see where to put b2:b12

4 Answers 4

0

You really need two conditions

1) Column B is equal to =MAX(IF(C2:C12<6,B2:B12))

2) Column C is <6

so you can INDEX column C when those two are met, i.e.

=INDEX(C2:C12,MATCH(1,(B2:B12=MAX(IF(C2:C12<6,B2:B12)))*(C2:C12<6),0))

confirmed with CTRL+SHIFT+ENTER

Sign up to request clarification or add additional context in comments.

2 Comments

WORKS omg thank you, this was a lot more complicated than i thought!!!!
i tried to give you a point too but i don't have enough posts, can't thank you enough
0
{=IF(C2<6,INDEX($C$2:$C$12,MATCH(MAX($B$2:$B$12),$B$2:$B$12,0)),0)}

3 Comments

this is close but it gives me 10 instead of 2? i think it's looking at the entire b column
I think it depends on how you put your formula, should work fine if you put it in D2 then copy paste down, if you want to validate D2:D12 at once use {=IF(C2:C12<6,INDEX($C$2:$C$12,MATCH(MAX($B$2:$B$12),$B$2:$B$12,0)),0)}
This would be a better answer if you explain how it works.
0

You were almost there.. Basically if C<6 , find max of B , lookup it in B:C and display corresponding C

{=IFERROR(VLOOKUP(MAX(IF(C2:C12<6,B2:B12, 0)),B2:C12,2,FALSE),0)}

Since your question doesn't clarify what if c>=6 I assume you don't want value. Can answer more precisely if you clarify.

Mark this as answer if that's correct. Hope this helps!

3 Comments

make sure column b dont have 0 value.. as if clause returns 0 and vlookup will still bring that value. In that case replace 0 with some other value in this formula.e.g. {=IFERROR(VLOOKUP(MAX(IF(C2:C12<6,B2:B12, -1)),B2:C12,2,FALSE),-1)}
is it possible to use index instead of vlookup...like =INDEX(C2:C12,MATCH(MAX(IF(C2:C12<6,C2:C12)),C2:C12,0)) is close but i don't see where I put b2:b12? Thank you!
@hollyolly Please see my answer if you would like a single INDEX() solution
0

As I could see you requested a single INDEX formula:

{=INDEX($C$2:$C$12,MATCH(MAX(IF($C$2:$C$12<6,$B$2:$B$12,0),0),IF($C$2:$C$12<6,$B$2:$B$12,0),0))}

This is an array formula, hit Ctrl+Shift+Enter while still in the formula bar.

Lets break this down.

=INDEX(C:C, - Index column C as these are the values you want returned

MATCH(IF(C:C<6,B:B,0), - Find the largest value from the following array in the array and return it's relative position for INDEX()

IF(C:C<6,B:B,0),0)) - If the value in column c is less than 6 then add the column B value to the array, otherwise add 0

2 Comments

Thanks! I missed this
Works great. Thanks for the detailed explanation..when I get enough credits I'll give you a point. I'm not sure if I can select 2 answers as correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.