+ Reply to Thread
Results 1 to 9 of 9

VBA countifs super slow

  1. #1
    Registered User
    Join Date
    07-08-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    21

    VBA countifs super slow

    Hi

    I have a long list of order lines which will vary in size from 1000 to 50000+ rows.

    Something like this:


    Order No: Item Start Time
    3000 Phone 30/06/2016 12:12
    3000 Memory Card
    3000 Cover
    3001 Phone
    3001 Memory Card
    3002 Phone 30/06/2016 11:26
    3002 Memory Card
    3002 Cover

    I need to filter so I see all order lines for the orders that have a start time.

    So after my filter I would need to see this:

    Order No: Item Start Time
    3000 Phone 30/06/2016 12:12
    3000 Memory Card
    3000 Cover
    3002 Phone 30/06/2016 11:26
    3002 Memory Card
    3002 Cover


    My order number is in column E, and my other criteria is in column AA

    My idea (which I got from this forum ) was to add a column (AK) with a countifs formula, and since I'm moving some data around later I wanted to copy/paste values.

    My code works, but it is very, very slow.
    Please Login or Register  to view this content.
    Later in the code I do the actual filtering based on my countifs results, but that part works fine.

    Is there a faster way to handle the countifs?

    Or is there a different way to filter this?
    Last edited by Gekko42; 07-03-2016 at 04:39 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: VBA countifs super slow

    Try:
    Please Login or Register  to view this content.
    Please note how use of code tags improved readability above, and take action:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this request is fulfilled, as per Forum Rule 7)
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    07-08-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA countifs super slow

    Thank you for the reply Kaper.

    Apologies for the missing tags. They should be in now.

    I tried your code and it's a lot faster than mine.

    Unfortunately it doesn't give the correct results.
    As far as I can see it gives TRUE if the first order lines on an order have a start time, but if the start time is one the second or third order line it will give FALSE.

    Most of my orders will have multiple order lines but only one of them (not necessarily the first one) with a start time and I need those orders to be tagged TRUE as well.
    I have attached a sheet that shows a bit better what I mean.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: VBA countifs super slow

    Try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-08-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA countifs super slow

    Thanks jindon, but you lost me on how this code works :P and it doesn't seem to do anything when I run it

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: VBA countifs super slow

    See the attached.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    07-02-2016
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    2

    Re: VBA countifs super slow

    Hi you can also, use a pivot table and filter as per you selection criteria and then show the values on a separate home page or pivot table it self. SO basically this can easily be done using s pivot table that using a VBA macro.

    Of course you can use a macro to do you filtering for you too.

    Mera - https://macroprog.blogspot.com/

  8. #8
    Registered User
    Join Date
    07-08-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA countifs super slow

    That worked perfectly jindon.

    I added it to my bigger data file and it gives me the correct result in a second My old one was running for minutes if I was lucky!!

  9. #9
    Registered User
    Join Date
    07-08-2012
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    21

    Re: VBA countifs super slow

    Thanks for the input mamanton10.

    My issue was that it was other users needing to pull this data and they are not very Excel or IT minded.
    I needed a macro to do the work for them.

+ 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. Super Slow Excel
    By graemearthur in forum Excel General
    Replies: 12
    Last Post: 12-23-2015, 03:38 PM
  2. General help simplifying my super slow VB code PLEASE :-D
    By blackcat_78uk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2015, 05:22 PM
  3. General help simplifying my super slow VB code PLEASE :-D
    By blackcat_78uk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-30-2015, 04:02 PM
  4. Super slow Insert Columns with 40,000 lines of records
    By stewegg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-08-2014, 01:48 PM
  5. [SOLVED] Need help with an excel file that is super slow and crashes a lot.
    By regorih in forum Excel General
    Replies: 6
    Last Post: 01-14-2014, 07:23 PM
  6. Tons of Arrays = Super Slow Calculating
    By danmarsh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-23-2012, 01:52 PM
  7. speeding up code that is super slow
    By cabinetguy in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 05-19-2011, 12:24 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