+ Reply to Thread
Results 1 to 2 of 2

Run-time error 91 - Help!

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Run-time error 91 - Help!

    Hi there.

    I am having a problem with some code and wonder if you could help me out. I am using an Activex Combo box to set the display levels in a worksheet.
    the code is as follows:

    Please Login or Register  to view this content.
    When I make a selection, in the combo box the code executes exactly how I want it to and everything is fine.

    My problems occur when I try to save and exit the spreadsheet. At this point I get the run-time error 91. Object variable or with block variable not set. On selecting debug it highlights the statement within the valid case for the current combo box selection. (I hope I'm making sense here).

    Being a bit of a noob at all this and having no idea what this was talking about, I tried looking it up on the net. Now I found plenty of explanations as to what object variables etc actually are, and I am sure they are perfectly valid. I have to confess though that I am still non the wiser. Not really surprising on my part as I generally find that most explanations when it comes to IT are over my head until I actually see something working. Once I see the correct syntax, and step through the code though, enlightenment often follows! I guess I shouldn't plan a career in this area huh!

    I would be very grateful if someone could give me some pointers and the correct syntax so's I can sort this and have a stab at understanding what's happening here as well.

    Many thanks

    Moderator's Edit: Use code tags when posting code. To do so in future, select your code and click on the # icon at the top of your post window.
    Last edited by arlu1201; 01-09-2013 at 02:09 PM.

  2. #2
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: Run-time error 91 - Help!

    When you are exiting the workbook the ActiveX combo may loose its value and at some point there will no longer be an active sheet either. I think a possible solution may be to ensure the event (of a changing value in the combo box) is no longer triggered. this may be possible by disabling event handeling

    Try adding the following routine to the workbook

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  3. #3
    Registered User
    Join Date
    01-09-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    1

    Re: Run-time error 91 - Help!

    Ollie B

    I tried your suggestion but I'm still getting the run-time error. Tried it in module, this worksheet and in the actual sheet itself, but no joy. Many thanks for taking the trouble to reply though. I appreciate all the help I can get.

    Moderator

    My apologies. I will use the code tabs next time I post any code as directed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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