make a long formula short

  • Thread starter Thread starter Niccalo
  • Start date Start date
N

Niccalo

as you can see below this is a monster! I have broken it up for ease o
read, is there any way to make it shorter?

=IF(AND(B7="R",F15=0)

VLOOKUP(D15,R2B!RD0,2,FALSE)

IF(AND(B7="R",F15=1)

VLOOKUP(D15,R2B!RD1,2,FALSE)

IF(AND(B7="R",F15=2)

VLOOKUP(D15,R2B!RD2,2,FALSE)

IF(AND(B7="R",F15=3)

VLOOKUP(D15,R2B!RD3,2,FALSE)

IF(AND(B7="R",F15=4)

VLOOKUP(D15,R2B!RD4,2,FALSE)

IF(AND(B7="R",F15=5)

VLOOKUP(D15,R2B!RD5,2,FALSE)

IF(AND(B7="R",F15=6)

VLOOKUP(D15,R2B!RD6,2,FALSE)

IF(AND(B7="R",F15=7)

VLOOKUP(D15,R2B!RD7,2,FALSE)

IF(AND(B7="R",F15=8)

VLOOKUP(D15,R2B!RD8,2,FALSE)

IF(AND(B7="R",F15=9)

VLOOKUP(D15,R2B!RD9,2,FALSE)

IF(AND(B7="R",F15=10)

VLOOKUP(D15,R2B!RD10,2,FALSE)

IF(AND(B7="R",F15=11)

VLOOKUP(D15,R2B!RD11,2,FALSE)

IF(AND(B7="R",F15=12)

VLOOKUP(D15,R2B!RD12,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=0)

VLOOKUP(D15,L2B!LD0,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=1)

VLOOKUP(D15,L2B!LD1,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=2)

VLOOKUP(D15,L2B!LD2,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=3)

VLOOKUP(D15,L2B!LD3,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=4)

VLOOKUP(D15,L2B!LD4,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=5)

VLOOKUP(D15,L2B!LD5,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=5)

VLOOKUP(D15,L2B!LD5,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=6)

VLOOKUP(D15,L2B!LD6,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=7)

VLOOKUP(D15,L2B!LD7,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=8)

VLOOKUP(D15,L2B!LD8,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=9)

VLOOKUP(D15,L2B!LD9,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=10)

VLOOKUP(D15,L2B!LD10,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=11)

VLOOKUP(D15,L2B!LD11,2,FALSE)

IF(AND(OR(B7="L",B7="S"),F15=12)

VLOOKUP(D15,L2B!LD12,2,FALSE
 
I'm probably missing something, but how can you have the reference R2B!RD0

isn't that referencing row 0? If it's a named range you wouldn't use the
R2B! part in front of it.. and a named range with a '!' is not valid.

anyways, if you want to use the value of F15 in your formula (since your
pattern uses the same F15 value as what comes after "RD"), you can do so
with this type of formula:

=IF(B7="R",VLOOKUP(D15,INDIRECT("RD"&F15),2,FALSE),"")

If this works for you, you can add in the other AND/OR parts and the other
(single) lookup formula.
 
Back
Top