+ Reply to Thread
Results 1 to 4 of 4

Error handling not working in "vba object variable or with block variable not set" in Loop

  1. #1
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Error handling not working in "vba object variable or with block variable not set" in Loop

    Hi


    I have On Error "GoTo ErrorHandler" in my code

    It works fine in first loop and Goes to ErrorHandler on error but in second loop of 'heads' it gives error as follows.

    "vba object variable or with block variable not set"

    Please Login or Register  to view this content.

    Note: Error is happening because in both of 1st and 2nd loop the value is not found from the sheet. That is Ok but I want the code to go to ErrorHandler: when there is error in 2nd loop, instead of showing the error.

    Thanks
    Last edited by caabdul; 11-23-2019 at 06:40 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: Error handling not working in "vba object variable or with block variable not set" in

    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Error handling not working in "vba object variable or with block variable not set" in

    As to why it happens: http://excelmatters.com/2015/03/17/on-error-wtf/
    Rory

  4. #4
    Forum Contributor
    Join Date
    12-25-2011
    Location
    Lahore, Punjab, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    287

    Re: Error handling not working in "vba object variable or with block variable not set" in

    Thanks Rorya, it worked

+ 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] exit a form getting "Runtime Error 91: Object variable or with block variable not set"
    By Hammer_757 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-09-2019, 08:49 AM
  2. [SOLVED] Object variable or with block variable not set "Run time error 91"
    By imzhakmaya in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2014, 06:54 AM
  3. Getting "Object variable or With block variable not set" error with Find function
    By enphynity in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2013, 05:47 PM
  4. [SOLVED] Runtime Error "91" - Object Variable or With Block Variable not set
    By damidre in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-05-2013, 04:45 AM
  5. Replies: 1
    Last Post: 09-07-2012, 12:08 AM
  6. Error msgs: "Object varible or with block variable not set"; "subscript out of range"
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-26-2009, 04:58 PM
  7. Keep getting "Object Variable or With block variable not set" error with macro
    By MSFSC in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-17-2009, 09:02 AM

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