Thread: close UserForm
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
katrina katrina is offline
external usenet poster
 
Posts: 7
Default 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