+ Reply to Thread
Results 1 to 7 of 7

Run-time Error 5 "Invalid Procedure Call or Argument"

  1. #1
    Registered User
    Join Date
    04-09-2014
    Location
    bangalore
    MS-Off Ver
    2010
    Posts
    15

    Run-time Error 5 "Invalid Procedure Call or Argument"

    Hi Guys,
    I am getting, Run-time Error 5 "Invalid Procedure Call or Argument" at the this part of the code.

    "o = Left(Cells(a, b).Value, (InStr(1, Cells(a, b).Value, "-") - 1))" . I am not able to figure out the problem.



    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    02-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    187

    Re: Run-time Error 5 "Invalid Procedure Call or Argument"

    Blimey!

    First off, I'd change your variable names to something more reflective of what they contain, makes the code much easier to read!

    As for the error, (without knowing what you want the code to do), try the following:

    Please Login or Register  to view this content.
    Hope that helps,

    TKCZBW

  3. #3
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Run-time Error 5 "Invalid Procedure Call or Argument"

    in the VBE (VBA Editor) make sure Watch window is shown (if not, go to View --> Watch Window).
    In the Watch Window (Watches) drag-and-drop a, b, c from your code and then create a breakpoint at row: Left(Cells(a, b).Value, (InStr(1, Cells(a, b).Value, "-") - 1)) (select the row then press F9). Then press F5 to have the code ran until the breakpoint then check the values for a, b, and c and see whether they make sense or not.
    Click on the star if you think I helped you

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Run-time Error 5 "Invalid Procedure Call or Argument"

    If there isn't a "-" in the cell.value, the Left function would error because its End argument would be -1

    Try something like this...
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  5. #5
    Registered User
    Join Date
    04-09-2014
    Location
    bangalore
    MS-Off Ver
    2010
    Posts
    15

    Re: Run-time Error 5 "Invalid Procedure Call or Argument"

    Hi
    0-10 10-20 20-30 30-40 40-50 50-60 60-70

    These are the values I have in the celss, all I am trying to do is, seperate numbers in the string, i mean 0,10,20,30 etc

  6. #6
    Valued Forum Contributor adyteo's Avatar
    Join Date
    01-10-2013
    Location
    Calgary
    MS-Off Ver
    Excel 2010
    Posts
    540

    Re: Run-time Error 5 "Invalid Procedure Call or Argument"

    dinakar, did you try to debug the code the way I described you above?

  7. #7
    Forum Contributor
    Join Date
    02-28-2012
    Location
    London, England
    MS-Off Ver
    Excel 2003, 2007, 2010
    Posts
    187

    Re: Run-time Error 5 "Invalid Procedure Call or Argument"

    Having run the code I provided above, it certainly works for 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. WritetoSheet causing "invalid procedure call or argument"
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-11-2013, 03:46 PM
  2. 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
  3. "Invalid procedure call or argument" error when creating Pivot table
    By Kaigi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2009, 06:02 AM
  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

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