+ Reply to Thread
Results 1 to 6 of 6

Fastest Way for Lookups

  1. #1
    Registered User
    Join Date
    02-13-2017
    Location
    Pittsburgh
    MS-Off Ver
    2013
    Posts
    3

    Fastest Way for Lookups

    Hello:
    I wrote a sub that takes a region, store id, and item code and searches for the combination on another data sheet. For example, it may have "east", "009473209" and "484475595" respectively, and it looks at the data sheet for the exact match of those 3 things and returns the sales. The data sheet has region in A, store # in B, item # in C, and sales in D. The problem is that the master data list has over 90,000 rows, and I need to search through about 350 stores for each item. I wrote nested for statements, and it takes forever to run.
    The basic structure is:

    get the region
    get the item id

    for every store
    get the store number
    for every data row
    search for the unique combination of region, store, and item
    end of inside for
    end of outside for

    Is there any faster way to do this? Should I be using vlookups or something instead?
    Thanks for the help.

  2. #2
    Registered User
    Join Date
    01-20-2017
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    199

    Re: Fastest Way for Lookups

    I prefer using Index Match for these cases. Could you attach a short version of your file with a few test sets of data?

  3. #3
    Registered User
    Join Date
    02-13-2017
    Location
    Pittsburgh
    MS-Off Ver
    2013
    Posts
    3

    Re: Fastest Way for Lookups

    This is a basic file to simulate the actual one. But in the actual one, the FY16 tab has over 90000 data points and the East tab has over 3500 stores.
    Attached Files Attached Files

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Fastest Way for Lookups

    Try this for starters.
    Fill Region and ItemNumber and press CTRL+SHIFT+I.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Registered User
    Join Date
    02-13-2017
    Location
    Pittsburgh
    MS-Off Ver
    2013
    Posts
    3

    Re: Fastest Way for Lookups

    Thanks bakerman. That runs a column in about 10 minutes, which is a ton of improvement on my ugly code. Is there any faster way than making a filter each time?

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,909

    Re: Fastest Way for Lookups

    If you can post a example file with a larger set of data so I can test properly maybe we can speed things up some more.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 12-18-2014, 09:43 PM
  2. What are the fastest and best URL text only extractors out there?
    By Dimple777 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-18-2013, 01:28 PM
  3. Fastest Times
    By soss in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-13-2007, 02:09 PM
  4. what is the fastest excel machine I can get?
    By davidstone in forum Excel General
    Replies: 1
    Last Post: 08-29-2006, 07:42 AM
  5. Replies: 2
    Last Post: 05-16-2005, 12:07 AM
  6. Replies: 1
    Last Post: 05-15-2005, 07:07 PM
  7. Is this the fastest way to do it?
    By routeram in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-17-2005, 05:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1