Results 1 to 3 of 3

Run-time error 91 - Help!

Threaded View

  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:

    Private Sub cmbDisplaylevel_Change()
            Select Case cmbDisplayLevel.Value
                Case Is = 1
                    ActiveSheet.Outline.ShowLevels RowLevels:=3
                Case Is = 2
                    ActiveSheet.Outline.ShowLevels RowLevels:=2
                Case Is = 3
                    ActiveSheet.Outline.ShowLevels RowLevels:=1
            End Select
    End Sub
    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.

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