+ Reply to Thread
Results 1 to 5 of 5

faster way to loop

  1. #1
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    faster way to loop

    I have a pivot table and I need the fastest way to pull values below.


    In Workbooks("ABC").Sheets("AAA").Range("A24")
    need to get column D where:
    column A = "Dog"
    column B = 42248
    column C = "San Jose"



    there are about 85,000 rows that varies some each day


    Here is my current code
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: faster way to loop

    You could try filtering on the entire dataset then doing all the work at once, then unfiltering.
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: faster way to loop

    This is a very slow method.

    You are actually looking at each cell in column A. Ok if there only a few rows

    But when there are thousands this is very slow.

    Try using the Find function.

    There are two approaches that I would use Depending on your data.

    Solution A:

    Search for your search data in column A and check if B and C also match.

    Solution B:
    use Countif on columns A, B and C to find how many times your search data appears in those columns.
    If we search for the least common result then we could be minimising our work.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by mehmetcik; 04-22-2015 at 12:03 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  4. #4
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: faster way to loop

    I am trying the Find Function and it works with 2 variables, but how do I get 3 variables? Can you see what is wrong? Thanks for the help

    Here is what works with 2:
    Please Login or Register  to view this content.
    Here is what I tries with 3
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: faster way to loop

    I got it thanks. I didnt have the cVal As String. Thanks for the help

+ 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. Is it possible to get rid of this loop to make the code faster?
    By mhw1129 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2011, 09:03 AM
  2. Make loop run faster
    By losmi8 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-20-2010, 01:11 AM
  3. Faster Way to Loop for Price Indexing
    By lopiner in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-11-2009, 03:08 PM
  4. Making a simple loop faster
    By gummi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-23-2008, 07:07 PM
  5. [SOLVED] Faster For-Next Loop?
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2005, 06:06 PM

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