How can I lookup a value in Excel using two input cells ?

Hi Experts,

I'm trying to build an Excel formula which will use TWO lookup values to return a cell value in a range.

I've attached an example sheet of what I'm trying to do. It consists of a lookup table of 3 columns showing the distances in miles from a list of various UK towns to Birmingham and also to Manchester.

I want the user to select a town from the dropdown list in the 'From' cell, and to select a town from the dropdown list in the 'To' cell. On  a correct match in the lookup table, the value returned should be displayed in the 'Mileage' cell.

It is assumed that either Birmingham or Manchester will be selected from at least one of the dropdown lists.

I've tried INDEX/MATCH but can't get the result I need.

Many thanks
Toco
TocogroupAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

[ fanpages ]IT Services ConsultantCommented:
"I've attached an example sheet of what I'm trying to do..."

(Nothing attached)
0
CamyCommented:
Don't think you included the attachment?
0
TocogroupAuthor Commented:
Sorry about that.
Mileage-Calculator.xlsx
0
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Roy CoxGroup Finance ManagerCommented:
Just a very quick guess. The example uses two Forms ComboBoxes.
INDEX-FORMULA.xlsx
0
Roy CoxGroup Finance ManagerCommented:
Just seen the example, maybe this
Mileage-Calculator.xlsx
0
[ fanpages ]IT Services ConsultantCommented:
This formula may be placed in cell [C8]:

=IF(OR(C5="Birmingham",C5="Manchester"),VLOOKUP(C6,E7:G17,1+MATCH(C5,F6:G6,0),FALSE),IF(OR(C6="Birmingham",C6="Manchester"),VLOOKUP(C5,E7:G17,1+MATCH(C6,F6:G6,0),FALSE),"Invalid"))

Please see the attached workbook.
Q-28671036.xlsx
0
TocogroupAuthor Commented:
Hi Roy,

I seem to be getting the wrong mileage in some cases, For example, Aberdeen to Birmingham
0
[ fanpages ]IT Services ConsultantCommented:
^ 423 (as expected) is the value for Aberdeen to Birmingham, & also for Birmingham to Aberdeen, in my suggestion.

PS. A slightly shorter formula; taking the lookup values of "Manchester" & "Birmingham" from the titles of the two columns (cells [F6] & [G6]):

=IF(OR(C5=F6,C5=G6),VLOOKUP(C6,E7:G17,1+MATCH(C5,F6:G6,0),FALSE),IF(OR(C6=F6,C6=G6),VLOOKUP(C5,E7:G17,1+MATCH(C6,F6:G6,0),FALSE),"Invalid"))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TocogroupAuthor Commented:
That's great. Just what I wanted and works consistently.
Many thanks
Toco
0
[ fanpages ]IT Services ConsultantCommented:
You're very welcome.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.