+ Reply to Thread
Results 1 to 6 of 6

Invalid procedure call or argument (Error 5)

  1. #1
    Registered User
    Join Date
    03-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    15

    Invalid procedure call or argument (Error 5)

    Hi Experts.

    I am getting this error "Invalid procedure call or argument (Error 5)"

    in this statement below.

    thecounty = Log(thecountxp)

    I defined the county as double but looks like value is going out to the limit hence I am getting it. Is there a way to get rid of this error ?

    Many thanks in advance,

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: Invalid procedure call or argument (Error 5)

    Works for me:

    Please Login or Register  to view this content.

    What value does thecountxp have and how is it defined?


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    03-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Invalid procedure call or argument (Error 5)

    I defined same way u did. value of xp is small than yours ( not 10 ) , it is long cacluated value results as "-86.83176087"

    calucaltion of XP is like below. I know it is crazy calucation but I have no other choice ,
    thecountxp = Range("C13") * Range("C14") / Range("C14") + vt * (xf - 1) - Sqr(Range("C13") * Range("C14") / Range("C14") + vt) * (xf - 1) ^ 2 - 4 * ksp / 2


    thecountxp is coming = "-86.83176087" so when i do

    TheCountY = Log(TheCountXP) then I get this error. Any help would be appreciated much.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: Invalid procedure call or argument (Error 5)

    Can you have the Log of a negative number? Rhetorical question: no you can't. Google: log of negative number

    Hence the reason you get the error.

    The routine below will cope with the situation and give an answer but the answer may not be useful in numeric calculations.

    Note Log(xy) = Log(x) + Log(y). So Log(-x) = Log(-1*x) = Log(x) + Log(-1)


    Please Login or Register  to view this content.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    03-21-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Invalid procedure call or argument (Error 5)

    Much appreciated TMS. I know we cant have log of negative number but I need to calculate this equation for a range. I agree with your advise and probably this is the only way to handle this situation.

    Regards,
    Vik

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,366

    Re: Invalid procedure call or argument (Error 5)

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Macro Error - Invalid Procedure Call or Argument
    By mcordi in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-12-2011, 05:40 PM
  2. Runtime Error 5: Invalid procedure call or argument
    By Arasi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-07-2009, 11:49 AM
  3. Invalid procedure call or argument error
    By Patrick Simonds in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2006, 06:45 PM
  4. Replies: 2
    Last Post: 02-24-2006, 05:30 PM
  5. 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

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