+ Reply to Thread
Results 1 to 12 of 12

Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

  1. #1
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    I have posted this question on Stackoverflow as well, it's been a week and unfortunately no solutions yet...
    https://stackoverflow.com/questions/...03012_62540181

    I have code in VBA that uses an Advanced filter to fill multiple tables. It worked without any errors before. I upgraded from Office 2013 to Office 365 and suddenly I get error messages on the code...

    The Advanced filter runs, fills, and filters the tables correctly but I still get an error message that pops up "Excel ran out of resources while attempting to calculate one or more formulas. As a result, these formulas cannot be evaluated". If I press okay another error shows "Run-time Error 1004: Advanced Filter method of range class failed". this is strange since it still does the filtering and filling correctly... The file contains no formulas, 30500 rows, 37 columns.

    I've searched for solutions online and tried a couple but none have worked so far. I've tried the following:
    • Closing down all Excel applications and run macro again
    • closing down all application and only running Excel
    • Reduce the core processors for Excel from 4 to 2
    • Turn off the Multi-threaded calculation in Advanced options
    • Remove all .COM add-ins
    • Reduce the file to only use 100 rows and not the full file, tried 50 as well
    • Tried manually using the advanced filter, which doesn't work anymore, I get the same error messages


    I use advanced filter about 20 times in the code, so it's a bit of a problem. One section of the code looks like this (all 20 sections for the advanced filter are structured the same):

    Please Login or Register  to view this content.
    The bottom part is where the error pop's up, on this line for the advanced filter.

    Please Login or Register  to view this content.
    Does anyone know why this is suddenly happening and how I can fix the problem, please?

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Hi Simone

    Any chance of a sample file upload so we can see what data Table_Corporate_Order_Compliance3 houses and see what is actually filtered...
    I use advanced filter about 20 times in the code
    Perhaps time for a simplification...
    Last edited by Sintek; 06-29-2020 at 10:54 AM.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Hi Sintek,

    Just so I'm clear. Do you want me to upload a small sample size of ONLY the final table with data was filtered and filled in? The numbers are correct, I did check that just in case...
    Not sure how this would help but if it sheds some light on my situation I will gladly do that.

    The reason I'm using Advanced filter about 20 times is because I need to fill different reports with different data, from either the same raw data table or different multiple ones. I'm not sure if there is an easier way, but it there is I'm all ears!

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    I would guess only the table and data that pertains to that specific code snippet...

    You are setting up the criteria range in a new sheet to use as a criteria when filtering data in a Table...i.e Table_Corporate_Order_Compliance3
    Also what is the value of VRegion - A named range I guess

    Are all 20 procedures the same basic setup

    I do not see you setting your ranges to nothing to clear up memory after...although mostly it clears itself when runs out of scope...depending on the complexity...
    Last edited by Sintek; 06-29-2020 at 12:02 PM.

  5. #5
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    I've attached a sample file with the template/table that it copies to and the data that it added (which is the correct amount).
    I've added another sheet with the Filter criteria on there as well, and added 2 more examples as it would normally look. Normally the filter criteria is in the same workbook as the raw data that gets filtered(just a different sheet). This has worked absolutely fine before.

    VRegion is a string variable that the user sets right at the start with a listbox. In this cases it's "EC".

    Yes, all the advanced filter setups run the same/have been coded the same, if that's what you're asking?

    Just to show where the advanced filter runs after each other in this example, If added another part of the codes below. No I don;t think I clear the ranges, I sometimes use the same raw data range to filter, so no need to clear, and the Filter criteria is all set for there own range and variable (see below). Will it be best to change this?

    Please Login or Register  to view this content.

    Please let me know if I need to supply more data or code that will help.
    I appreciate the help!
    Attached Files Attached Files

  6. #6
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Unfortunately not able to test as all the ListObjects are not available...
    Will need a working sample file...

    ListObjects("Table_Franchise_Order_Compliance")
    ListObjects("Table_SDCdata")

    Also, if possible, please explain what you are actually trying to achieve with your current code...
    Don't think anyone else will be able to assist within more info...
    Last edited by Sintek; 06-30-2020 at 07:17 AM.

  7. #7
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    I've attached a new workbook with the 'Franchise' templeate on as well, adn added another workbook with sample SDC data. I've moved the 'FltrCrit' sheet to the raw data (SDC workbook) as well as it would normally be. I know the code I pasted creates the FltrCrit sheet, but I added it just for exmaple, it can obviously be deleted if neccessary.

    I've manually tested the advanced filter on the test samples I've attached. Strange thing is that is doesn't work now manually...before it did. I have to convert the template table to range, do the advanced filter, then I still get the same error, but it still filters and copies correctly (as with the VBA code).

    To explain what the code does:
    I have a big raw data file and I need to create different reports from it, thus needing to filter different criteria and copy that data to the specific report/template. In this case Franchise report and Corporate report. But there are more reports with different criteria from different files as well.
    The problem I'm having is that it keeps giving me an error (as explained in the main post), even though it is correctly filtering and copying the correct data.
    Attached Files Attached Files

  8. #8
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Hi Simone...

    I notice that your Filter Criteria is hard coded...
    Is this the same for all 20 Advance filter setups and is always the same throughout your extractions...

  9. #9
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Yes, it's the same throughout for all Advanced Filter criteria. When I started coding it I was looking for a way not to hard code it but I couldn't find any suggestions, unfortunately. I'll be very happy if I don't have to do it that way.

  10. #10
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    K...Will have a look in the morrow...

  11. #11
    Registered User
    Join Date
    12-15-2014
    Location
    Wales, UK
    MS-Off Ver
    365
    Posts
    66

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Thank you! I really appreciate the effort!

  12. #12
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Excel VBA with Advanced Filter “Error: Excel Ran out of resources”

    Morning Simone...

    I've made a few adjustments in your code to give you an idea of how you could implement a more simplistic approach...
    Also noticed that you code crashes if the ListObjects have no data...

    I am not sure how the other 18 filter code snippets look but you did mention that they are similar and if they are all hard coded that must mean that your EXTRACTION is always the same...
    Perhaps you would be able to simplify the entire macro...can only say once I see all the code and get an understanding of each extraction filter criteria...

    As to the reason why it errors, I cannot recreate...can only assume that with such a big macro and such alot of repetitive clunky code, anything could go wrong...
    Anyway...For your sample uploads, the following...
    As your filter criteria was the same, I just left the FiltCrit Table as a given and updated the StoreTypes only via code...
    I also change variable names so that I could understand the process...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Sintek; 07-01-2020 at 03:53 AM.

+ 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: 5
    Last Post: 05-31-2015, 12:53 PM
  2. Replies: 4
    Last Post: 05-10-2013, 12:45 PM
  3. Excel 2010 Ran out of resources while calculating error (but not in 2007)
    By wilki24 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-02-2012, 08:02 PM
  4. Excel VBA Error 'Excel Ran out resources' - Reg
    By Swaminathan Gopalan in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 05-18-2012, 03:22 AM
  5. Replies: 2
    Last Post: 03-03-2012, 03:43 PM
  6. Excel 2007 : Error - Excel has run out of resources!
    By rikkiholland in forum Excel General
    Replies: 7
    Last Post: 09-22-2009, 04:27 AM
  7. Replies: 3
    Last Post: 02-06-2009, 06:08 AM

Tags for this Thread

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