Solved

Match vs Loop

Posted on 2014-03-15
3
475 Views
Last Modified: 2014-03-16
I am curious of performance from doing a loop vs a Match function.  If I have a worksheet lets called parts with 10,000 rows and 15 columns.  I have another worksheet in the same workbook lets call regional daily orders.  If every day I review every row in the regional daily orders worksheet (daily row count of 500) for a column called part number and find the corresponding  part number in the worksheet called parts and store the value price and manufacture is this better accomplished with a loop or match function or something else.

I am pretty familiar with loops, but I do not want this to be a case where I am doing a loop for comforts sake...if there is a better method then I would like to learn..
0
Comment
Question by:upobDaPlaya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 250 total points
ID: 39931699
Without more information, a MATCH function in a formula will most definitely be faster than a VBA loop doing the same. Excel's built in functions are optimized compiled code that have access to many more underlying data structures than we do using VBA. They are optimized for performance while VBA is a more generalized and interpreted automation language.

Kevin
0
 
LVL 39

Assisted Solution

by:nutsch
nutsch earned 250 total points
ID: 39931704
As Kevin said much better than I can, I think the most straightforward way, and potentially the fastest, is to run a vlookup (or a match) in the worksheet, then paste the values, e.g.

sheets("Orders").range("E2:E6500").formular1c1="=vlookup(rC2,Parts!R1C1:R150000C15,3,0)"
sheets("Orders").range("E2:E6500").value=sheets("Orders").range("E2:E6500").value

Open in new window


then do the same for the manufacturer.

Thomas
0
 

Author Closing Comment

by:upobDaPlaya
ID: 39933418
I fooled around with a match function today...wish I knew of it earlier :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

696 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