+ Reply to Thread
Results 1 to 2 of 2

Run time error 5, invalid procedure call or argument

  1. #1
    Registered User
    Join Date
    06-02-2014
    Posts
    11

    Run time error 5, invalid procedure call or argument

    Hi,

    I have a code that filters out every possible filter for a pivot table and copy specific values to other sheet.
    It works fine, but it has suddenly crashed already twice.

    It goes like this:
    - Everything works fine;
    - Suddenly, without any logic, error appears in a middle of code doing its work. It loops through approx. 40 filters out of 70 and then crashes;
    - From now on, it will continue to crash at the same place;
    - If I will copy all data and file structure to a new workbook and will apply the same code, it will again work (due this I don't see any logic, why the code crashes).


    Any idea what this might be related to? New sheets added to workbook? New pivots created in a workbook?

    Code below (yellow - line where error appears):

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Run time error 5, invalid procedure call or argument

    You may consider adding a break point in your code, debug.print lines throughout and/or adding watches to variables and step through your code (F8) to trace the problem.

    The error generally has to do with trying to call a procedure or object/argument that is misspelled or for which the syntax is off the mark. This however can happen in loops when the loop arrives to a place outside the bounds of the objects/collection you are working within.

    The line you highlighted seems to me, out of context, to be redundant or at least more than what you may need. Your already via your For Each looping "selecting" your pivotitem, I am not sure what added value assigning the value of the pivot item to currentpage adds.

    More than likely at the step it fails the pivotitem value is not a valid currentpage value. For example the pivotitem having a value something like "Sheet 1" when the actual sheet is "Sheet1".
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

+ 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. [SOLVED] Run time error 5 - Invalid procedure call or argument
    By danbates in forum Excel General
    Replies: 2
    Last Post: 12-09-2017, 03:28 PM
  2. [SOLVED] Run time error 5 Invalid call procedure or argument
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2016, 06:31 AM
  3. Run-time error '5' - Invalid procedure call or argument
    By datutt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2015, 12:12 PM
  4. Run Time Error 5 Invalid Procedure Call or Argument
    By esong_98 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2015, 03:31 PM
  5. Run-time error 5, Invalid procedure call or argument
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-23-2014, 08:29 AM
  6. Run-time error '5': Invalid procedure call or argument
    By mcbruce76 in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 07-30-2013, 08:31 PM
  7. Run Time Error 5 - Invalid Procedure Call or Argument Q
    By John in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2005, 05:05 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