VB for Excel 2003, matrix question


I have a matrix of locations and milages that form a grid to figure out how many miles you have traveled from point a to point b.

I only really know about select case, and IF statements, but is there a better way to select info out of a matrix?  Say if a user selects location2 for their starting point, and then location 10 for their destination, I would need a user defined function to look up on the matrix and pull out the correct distance traveled.  That distance then needs to be placed in a resulting cell.

So I should have 3 variables right?  One for loc1, one for loc2 and then one to store the destination?

Thanks for pointing me in the right direction.

Who is Participating?
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.

Patrick MatthewsCommented:
Hi scott,

No need for a UDF.  Use INDEX() and MATCH().



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
scottman29Author Commented:
thanks I'll give it a try
Patrick MatthewsCommented:
Do you need this from code or from Excel UI?

If from the UI, and assuming that your locations are in Row 1 and Col A:


scottman29Author Commented:
is the match formula really needed?  It seems to work fine with just index...
Patrick MatthewsCommented:
Well, if it's working without MATCH, then I guess you don't need it :)

I typically find that I do, but then again I cannot see your worksheet.

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
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.