Need to calculate based on values from two separate drop down Lists

Copper Contributor

list of 16 cars, 16 brands and 16 different prices. I have a main sheet with my data, a second sheet with the table containing the drop down lists. My formula spills. I cannot for the life of me figure out what I'm missing. I've tried so many

=VLOOKUP('Main Sheet'!A4:A20,[@[From ]]&'Main Sheet'!A4:Q4,[@To],'Main Sheet'!B5:B20)

 

this is my latest. Anyone recognize what I'm missing? I know once I see it, I'll have that AHA moment

7 Replies

@Amanda535 

 

Without seeing your actual workbook, it's hard to be sure. I do notice that the first argument in your VLOOKUP formula is itself an array, and my own suspicion would be that that might be the problem. Usually one uses a single cell as the first argument.

 

If you were to post your actual sheet, we (I and others) could take a look at it. Just make sure it's not got any confidential info on it

@Amanda535 

Lookup value here is an array, formula returns an array for which is not enough space in one cell of the table, thus #SPILL error

image.png

What other parameters mean is also absolutely unclear (second one is value instead of range, etc)

@mathetes just getting laptop back thanks so much for response. I've attached sheet

 

@Amanda535 

That could be

=IFNA(INDEX('Main Sheet'!$A$4:$Q$20,
           MATCH([@[From ]],  'Main Sheet'!$A$4:$A$20,0),
           MATCH([@To],'Main Sheet'!$A$4:$Q$4,0)),0)

 

@Amanda535 

 

@Sergei Baklanhas given you the formula that handles your initial request. I've tweaked the spreadsheet just a bit more and suggest you not "hard-code" the mileage rate into the formula, as you had it. Instead, create a named range where that rate is called "MileageRate" and then your formulas will just refer to that term. That way, next year, when the rate gets changed (or after you've exceeded the 5,000 Km limit, the rate can be changed at the level of that little table rather than editing each formula.

You guys are the absolute best! I didnt even try the match thanks so much for you help. Now I'll never forget it

@Amanda535 

You are welcome.

If continue @mathetes idea, you may name range with Mileage Matrix let say as MileageMatrix, when formula could be

 

=IFNA(INDEX( MileageMatrix,
       MATCH([@[From ]],INDEX(MileageMatrix,0,1),0),
       MATCH([@To],INDEX(MileageMatrix,1,0),0)
),0)