Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
close UserForm
Received a runtime 91 error "Object variable or With block variable not
set" error when closing an user form. Excel debug go right to 'Load UserForm1" statement. All code run smoothly up to this point. Help! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
close UserForm
Sounds like you have an error in your code where you try to use an object
that is not set to a reference. Probably in some code that fires when the userform is closed. for instances if you had Private Sub Cmd_OK_Click() rng.Value = Textbox1.Value Unload me End sub if rng was not pointing to a range object, you would get such an error. -- Regards, Tom Ogilvy " wrote: Received a runtime 91 error "Object variable or With block variable not set" error when closing an user form. Excel debug go right to 'Load UserForm1" statement. All code run smoothly up to this point. Help! |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
close UserForm
Without seeing the code in the UserForm_Terminate event, it is difficult to
determine the cause of the problem. In order to have the editor take you to the offending line of code, in VBA go to the Tools menu, choose Options, then the "General" tab. There, select "Break In Class Module" instead of "Break On Unhandled Errors". -- Cordially, Chip Pearson Microsoft MVP - Excel www.cpearson.com (email address is on the web site) wrote in message oups.com... Received a runtime 91 error "Object variable or With block variable not set" error when closing an user form. Excel debug go right to 'Load UserForm1" statement. All code run smoothly up to this point. Help! |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
close UserForm
I'm having the same problem unloading a userform...thought until last night
that error 91 was caused by trying to show a highlighted default in the listbox because without the line .ControlSource = "Sheet1!AA19" everything worked fine. Last night I discovered the default and everything else worked without the Unload Me command except that the userform won't unload (Duh!) I tried Unload CropMonth, which is the name of the userform but I get the same error. It's a userform with only a single selection listbox which I want to default to the last selection when it initializes and close when the user clicks a selection. Here's the code: Private Sub ListBox1_Click() Sheets("sheet1").Range("AA19").Value = ListBox1.Value Unload Me '(everything works w/o this line except won't unload form.) End Sub Private Sub UserForm_Initialize() With ListBox1 .RowSource = "" .AddItem "N/A" .AddItem "January" .AddItem "February" .AddItem "March" .AddItem "April" .AddItem "May" .AddItem "June" .AddItem "July" .AddItem "August" .AddItem "September" .AddItem "October" .AddItem "November" .AddItem "December" .ControlSource = "sheet1!AA19" '(Everything works w/o this but no default.) End With End Sub I would also appreciate any help regarding this problem. Thanks, Katrina |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto close userform | Excel Discussion (Misc queries) | |||
Close button userform | Excel Programming | |||
Automatically close a userform | Excel Programming | |||
Close a userform | Excel Programming | |||
Userform Close button | Excel Programming |