locked
Run-Time Error '91' with a user form. RRS feed

  • Question

  • I have created a User form that i'm running in a macro using a hot key. All of my code is assigned to the User form and it runs perfectly until I close it and at the end it gives me the "Run-Time error '91' Object variable or with block variable not set" 

    When I hit Debug it only highlights the "frm33.show" in the macro

    The macro in my module only has this code

    Sub User_Form_33()

    frm33.show

    End Sub

    Monday, July 22, 2013 1:24 PM

Answers

  • Thanks, I Finally figured out I had another frm33.show in my Userform_initialize section of code. I just had to delete that and it works perfectly.  Your explanation however helped me understand the differences between the Userforms and the Modules, and how to debug with other problems.

    • Marked as answer by Damon Zheng Monday, July 29, 2013 6:03 AM
    Monday, July 22, 2013 3:26 PM

All replies

  • In the VBE, change from "Break on Unhandled errors" to "Break on All Errors" or "Break in Class Module".
    The code module behind a userform is a class module. Errors are handled differently there.
    (don't forget to change it back)
    '---
    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    • Edited by James Cone Monday, October 31, 2016 1:43 AM
    Monday, July 22, 2013 2:55 PM
  • Thanks, I Finally figured out I had another frm33.show in my Userform_initialize section of code. I just had to delete that and it works perfectly.  Your explanation however helped me understand the differences between the Userforms and the Modules, and how to debug with other problems.

    • Marked as answer by Damon Zheng Monday, July 29, 2013 6:03 AM
    Monday, July 22, 2013 3:26 PM