Solved

Match vs Loop

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
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…

867 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

18 Experts available now in Live!

Get 1:1 Help Now