[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB for Excel 2003, matrix question

Posted on 2006-04-12
5
Medium Priority
?
225 Views
Last Modified: 2010-05-01
Hi,

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.

yours,
Scott
0
Comment
Question by:scottman29
  • 3
  • 2
5 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 16437758
Hi scott,

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

Regards,

Patrick
0
 
LVL 5

Author Comment

by:scottman29
ID: 16437834
thanks I'll give it a try
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 16440751
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:

=INDEX(1:65536,MATCH(loc1,A:A,0),MATCH(loc2,1:1,0))

Patrick
0
 
LVL 5

Author Comment

by:scottman29
ID: 16441568
is the match formula really needed?  It seems to work fine with just index...
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 16442256
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.

Patrick
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question