+ Reply to Thread
Results 1 to 9 of 9

Object Variable or With block variable not set - Error 91

  1. #1
    Registered User
    Join Date
    05-02-2016
    Location
    Kenosha, Wisconsin
    MS-Off Ver
    MS 2010
    Posts
    4

    Object Variable or With block variable not set - Error 91

    Good day,

    I'm not the fondest when it comes to knowledge with Excel, so slightly asking a newbie question and looking for a possible resolution.

    The current output I have is as follows:


    Please Login or Register  to view this content.
    I've gotten this to work before without receiving this error, unsure of what I changed to get it to work to be honest. I've researched this throughout many points of google but stumped as to what is stopping this from working correctly.

    Any insight would be greatly appreciated and to help a newbie understand this.


    Thanks!!


    Shawn




    *Edit* When I close and reload the document, I receive a new error of 1004 - Out of Stack Space. This has got me confused even more now >,<
    Last edited by alansidman; 05-02-2016 at 07:21 PM. Reason: code tags

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Object Variable or With block variable not set - Error 91

    Have you protected the worksheet...?

  3. #3
    Registered User
    Join Date
    05-02-2016
    Location
    Kenosha, Wisconsin
    MS-Off Ver
    MS 2010
    Posts
    4

    Re: Object Variable or With block variable not set - Error 91

    Cytop,

    Worksheet was protected at one point with a password, upon doing so, is where I received the errors in that same variable. I've since then removed it but still showing an error for this string, now with the 1004 error...

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

    Re: Object Variable or With block variable not set - Error 91

    When are you running this code?

    Also, which worksheet in which workbook does ActiveWorkbook.Worksheets(1) refer to?
    If posting code please use code tags, see here.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,944

    Re: Object Variable or With block variable not set - Error 91

    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (Because you are new to the forum, I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  6. #6
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Object Variable or With block variable not set - Error 91

    Only asked about protection because of this:
    Please Login or Register  to view this content.
    To which you answered
    Worksheet was protected at one point with a password... since then removed it
    That code, then, does not reflect the current version of your code.

  7. #7
    Registered User
    Join Date
    05-02-2016
    Location
    Kenosha, Wisconsin
    MS-Off Ver
    MS 2010
    Posts
    4

    Re: Object Variable or With block variable not set - Error 91

    If you are referring to this then this is what the source would be.


    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Object Variable or With block variable not set - Error 91

    But the code STILL protects the sheet, then immediately tries to write to the sheet - that will throw a 1004 error.

  9. #9
    Registered User
    Join Date
    05-02-2016
    Location
    Kenosha, Wisconsin
    MS-Off Ver
    MS 2010
    Posts
    4

    Re: Object Variable or With block variable not set - Error 91

    I'll try to look at it to see what variations I can come up with in the code. Least that gives me a starting point to look over. Appreciate it.

+ 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] Run-time error '91': Object variable or With block variable not set when closing userform
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2016, 08:59 AM
  2. Replies: 2
    Last Post: 08-22-2014, 03:55 AM
  3. [SOLVED] Excel VBA error code 91: Object variable or with block variable not set
    By wilnexpc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-24-2013, 11:46 AM
  4. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  5. Object variable or With block variable not set Error during sorting program
    By BlahBlahBlahBlahBlah in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2012, 07:57 AM
  6. Error 91 object variable block variable not set when importing a CVS file
    By ReportBuilder2011 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2011, 11:48 AM
  7. Object variable or With block variable not set" error message
    By JoeS in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-22-2009, 11:51 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