Solved

Match vs Loop

Posted on 2014-03-15
3
378 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now