+ Reply to Thread
Results 1 to 3 of 3

" on error goto " not working on second time an error occurs

  1. #1
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    " on error goto " not working on second time an error occurs

    Hi all,

    I've got a bit of code that pulls data from a website and then handles it.
    Part of the code is the following:

    Please Login or Register  to view this content.
    where on encountering an error, going to nxc means skipping the whole code and goes to the "next cell" (hence nxc )
    When I run this on an url that would error out on the "title" line, it gracefully skips the code by going to nxc and then runs the next url.
    However, the next url errors out on the same line, yet instead of skipping it, it will give me an error saying :

    Run-time error '91':
    Object variable or With block variable not set


    I know what causes the error. I do not know why it won't skip to nxc the second time around.
    Does anyone have any bright ideas for me?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: " on error goto " not working on second time an error occurs

    You could just add this after the line that might error,
    Please Login or Register  to view this content.
    or, since you know the error that's occurring and why it's occurring, you could handle the error without using On Error Resume Next.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: " on error goto " not working on second time an error occurs

    Thanks norie.
    With my head too much into the code, I actually forgot to put the resume next before looping to the next cell.
    On error goto 0 would work if I didn't want to skip a whole bunch of code because the error basically means I returned an empty url.

    Thanks for pointing me to the obvious

+ 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] Error Occurs while running to On Error Goto Line3
    By moinsk21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2014, 02:37 PM
  2. GoTo compile error: "Expected: line number or label"
    By elfsprin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-29-2011, 09:21 PM
  3. "On Error GoTo" syntax problem
    By jonrayworth in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2006, 08:20 PM
  4. Alternative to "On Error GoTo 0" that takes macro to last command?
    By StargateFan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-25-2006, 01:10 PM
  5. [SOLVED] Can I place "On Error GOTO xxx" into module level?
    By Frederick Chow in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2006, 12:10 AM

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