+ Reply to Thread
Results 1 to 3 of 3

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

  1. #1
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

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

    In ThisWorkbook I have the following code:

    Please Login or Register  to view this content.
    This loads my userform when I open my workbook as intended. But when I click the red X in the upper right corner to close the userform I get "Run-time error '91': Object variable or With block variable not set" and it points to:

    Please Login or Register  to view this content.
    How do I correct this?
    Last edited by bishoposiris; 02-10-2016 at 09:00 AM. Reason: Solved

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

    Re: Run-time error '91': Object variable or With block variable not set when closing userf

    Why are you showing the userform the user has just tried to close using X?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-03-2009
    Location
    Cary, NC
    MS-Off Ver
    Excel 2016
    Posts
    109

    Re: Run-time error '91': Object variable or With block variable not set when closing userf

    I just realized what my error was. I had:

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    Once I deleted UserForm_Initialize() code it works fine.

    Thanks for your quick response though!

+ 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] getting run-time error 91 object variable with block variable not set
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-23-2015, 08:01 AM
  2. Run-Time error '91': Object variable or With block variable not set
    By bs04do in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-25-2014, 11:10 AM
  3. Run time error 91 object variable or with block variable not set
    By Nirakshana in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2014, 07:56 AM
  4. Replies: 0
    Last Post: 04-16-2013, 07:15 AM
  5. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  6. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  7. [SOLVED] Intermittent Run-time Error 91: Object Variable or With Block variable not set
    By fraanchtoast in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-29-2012, 10:11 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