+ Reply to Thread
Results 1 to 5 of 5

Run-time error 5, Invalid procedure call or argument

Hybrid View

cmb80 Run-time error 5, Invalid... 03-23-2014, 07:22 AM
Andy Pope Re: Run-time error 5, Invalid... 03-23-2014, 08:00 AM
Andy Pope Re: Run-time error 5, Invalid... 03-23-2014, 08:01 AM
cmb80 Re: Run-time error 5, Invalid... 03-23-2014, 08:20 AM
Andy Pope Re: Run-time error 5, Invalid... 03-23-2014, 08:29 AM
  1. #1
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Run-time error 5, Invalid procedure call or argument

    I get this message and it debugs to my code here. The part in red is where it is highlighted by VBA

    If Sheet7.Range("f1").Value <> "" Then
    For Each rcell In Sheet7.Range("f1:f" & maxrow1)
    url1 = rcell.Value
    
    Set http1 = CreateObject("MSXML2.XMLHTTP")
    Debug.Print url1
    http1.Open "GET", url1, False
    http1.send
    Text1 = http1.responseText
    len1 = Len(Text1)
    
    x = InStr(1, Text1, "<a href=" & Chr(34) & "#" & Chr(34) & " onclick=" & Chr(34) & "tz")
    If x > 0 Then
    date1 = Mid$(Text1, x + 37, 22)
    End If
    
    date1 = Replace(date1, "&month=", Chr(134))
    date1 = Replace(date1, "&day=", Chr(135))
    date1 = Replace(date1, "&", Chr(136))
    
    sDate = Mid(date1, InStr(1, date1, Chr(135)) + 1, (InStr(1, date1, Chr(136))) - (InStr(1, date1, Chr(135)) + 1)) _
            & "." & Mid(date1, InStr(1, date1, Chr(134)) + 1, (InStr(1, date1, Chr(135))) - (InStr(1, date1, Chr(134)) + 1)) _
            & "." & Left(date1, 4) & Chr(124)

    Anything obvious triggering this error?

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,487

    Re: Run-time error 5, Invalid procedure call or argument

    Impossible to tell from code snippet alone.
    The code compiles so it must be the values held in the variables.

    Use debugger to check content of the values and returned values from functions. Make sure the calculations result in positive values.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,487

    Re: Run-time error 5, Invalid procedure call or argument

    Impossible to tell from code snippet alone.
    The code compiles so it must be the values held in the variables.

    Use debugger to check content of the values and returned values from functions. Make sure the calculations result in positive values.

  4. #4
    Forum Contributor
    Join Date
    04-21-2009
    Location
    England
    MS-Off Ver
    Excel 2016
    Posts
    710

    Re: Run-time error 5, Invalid procedure call or argument

    Hi Andy - many thanks for your reply.

    Please advise how i'd go about doing the last sentence?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,487

    Re: Run-time error 5, Invalid procedure call or argument

    Quickest way, if you don't know how to use the debugging tools in VBE is to use Debug.Print command.
    This will output the values in the Immediate window. You can see the immediate window by typing CTRL+G in VBE

    
    debug.print date1
    debug.print InStr(1, date1, Chr(135)) + 1
    debug.print (InStr(1, date1, Chr(136))) - (InStr(1, date1, Chr(135)) + 1)
    
    sDate = Mid(date1, InStr(1, date1, Chr(135)) + 1, (InStr(1, date1, Chr(136))) - (InStr(1, date1, Chr(135)) + 1)) _
            & "." & Mid(date1, InStr(1, date1, Chr(134)) + 1, (InStr(1, date1, Chr(135))) - (InStr(1, date1, Chr(134)) + 1)) _
            & "." & Left(date1, 4) & Chr(124)
    add extra lines for other parts of the command.

+ 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. 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
  2. Macro Run Time error - Invalid procedure call or argument
    By clundeen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2011, 01:59 AM
  3. [SOLVED] 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. [SOLVED] 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