Home

Changing vlookup array based on a cell value

%3CLINGO-SUB%20id%3D%22lingo-sub-861552%22%20slang%3D%22en-US%22%3EChanging%20vlookup%20array%20based%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861552%22%20slang%3D%22en-US%22%3E%3CP%3EThere%20are%20different%20classifications%20for%20scores%20based%20on%20a%20student's%20grade.%26nbsp%3B%20I%20can%20do%20multiple%20IF%20statements%20(see%20column%20D)%2C%20but%20that%20requires%20filtering%20by%20grade%20and%20editing%20the%20formula%20several%20times.%26nbsp%3B%20Is%20there%20a%20way%20to%20do%20this%20with%20a%20Vlookup%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20does%20not%20work%20(see%20E2)%3A%3C%2FP%3E%3CP%3E%3DIF(B2%3D3%2C(VLOOKUP(c2%2C%24f%242%3A%24g%249%2C2))%2CIF(B2%3D4%2CVLOOKUP(c2%2C%24f%242%3A%24h%249%2C2))%2CIF(B2%3D5%2CVLOOKUP(c2%2C%24f%242%3A%24l%249%2C2))%2CIF(B2%3D6%2CVLOOKUP(c2%2C%24f%242%3A%24j%249%2C2))%2CIF(B2%3D7%2CVLOOKUP(c2%2C%24f%242%3A%24k%249%2C2))%2CIF(B2%3D8%2CVLOOKUP(c2%2C%24f%242%3A%24l%249%2C2)))%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-861552%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-861632%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20vlookup%20array%20based%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861632%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F411198%22%20target%3D%22_blank%22%3E%40plzsiga%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20it's%20possible%20to%20keep%20your%20sub%20level%20range%20in%20reverse%20order%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F132411i0A1B2E9D96BA263B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Ethe%20formula%20could%20be%20easier%2C%20like%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DVLOOKUP(%24C2%2CINDEX(%24O%242%3A%24U%242%2C%24B2-1)%3A%24V%249%2C10-%24B2)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EIf%20I%20understood%20your%20logic%20correctly.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-861643%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20vlookup%20array%20based%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861643%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F411198%22%20target%3D%22_blank%22%3E%40plzsiga%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20check%20out%20the%20below%20formula%3A%3C%2FP%3E%3CPRE%3E%3DINDEX(%24F%242%3A%24F%249%2C%3CBR%20%2F%3EIF(ISNUMBER(MATCH(C2%2CINDEX(%24G%242%3A%24L%249%2C%2CMATCH(B2%2C%24G%241%3A%24L%241%2C0))%2C0))%2C%3CBR%20%2F%3EMATCH(C2%2CINDEX(%24G%242%3A%24L%249%2C%2CMATCH(B2%2C%24G%241%3A%24L%241%2C0))%2C0)%2C%3CBR%20%2F%3EMATCH(C2%2CINDEX(%24G%242%3A%24L%249%2C%2CMATCH(B2%2C%24G%241%3A%24L%241%2C0))%2C-1)%2B1))%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20that%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-861752%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20vlookup%20array%20based%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861752%22%20slang%3D%22en-US%22%3EThank%20you!%20Than%20worked%20perfectly%2C%20too%2C%20and%20the%20'reversed'%20order%20was%20the%20original%20from%20the%20source.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-861756%22%20slang%3D%22en-US%22%3ERe%3A%20Changing%20vlookup%20array%20based%20on%20a%20cell%20value%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-861756%22%20slang%3D%22en-US%22%3EHatham%2C%20Thank%20you!%20It%20worked!%20It%20also%20was%20more%20accurate%20than%20my%20original%20code%20submitted.%20I%20guess%20I'm%20going%20to%20have%20to%20explore%20the%20INDEX%20and%20MATCH%20functions.%3C%2FLINGO-BODY%3E
plzsiga
New Contributor

There are different classifications for scores based on a student's grade.  I can do multiple IF statements (see column D), but that requires filtering by grade and editing the formula several times.  Is there a way to do this with a Vlookup?

 

This does not work (see E2):

=IF(B2=3,(VLOOKUP(c2,$f$2:$g$9,2)),IF(B2=4,VLOOKUP(c2,$f$2:$h$9,2)),IF(B2=5,VLOOKUP(c2,$f$2:$l$9,2)),IF(B2=6,VLOOKUP(c2,$f$2:$j$9,2)),IF(B2=7,VLOOKUP(c2,$f$2:$k$9,2)),IF(B2=8,VLOOKUP(c2,$f$2:$l$9,2)))

4 Replies

@plzsiga 

If it's possible to keep your sub level range in reverse order

image.png

the formula could be easier, like

=VLOOKUP($C2,INDEX($O$2:$U$2,$B2-1):$V$9,10-$B2)

If I understood your logic correctly.

@plzsiga

 

Hi,

 

Please check out the below formula:

=INDEX($F$2:$F$9,
IF(ISNUMBER(MATCH(C2,INDEX($G$2:$L$9,,MATCH(B2,$G$1:$L$1,0)),0)),
MATCH(C2,INDEX($G$2:$L$9,,MATCH(B2,$G$1:$L$1,0)),0),
MATCH(C2,INDEX($G$2:$L$9,,MATCH(B2,$G$1:$L$1,0)),-1)+1))

 

Hope that helps

Thank you! Than worked perfectly, too, and the 'reversed' order was the original from the source.
Hatham, Thank you! It worked! It also was more accurate than my original code submitted. I guess I'm going to have to explore the INDEX and MATCH functions.
Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies