View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed from AZ Ed from AZ is offline
external usenet poster
 
Posts: 120
Default Getting error with load/unload of UserForms??

My Workbook_Open() code is simply
UserForm1.Show

UserForm1 has four buttons. At this point, I'm only using CB2, which
has code
Private Sub CB2_Click()
Load UserForm2
End Sub

UserForm2_Initialize populates a ComboBox on the Form with the names
of the worksheets and then executes
Unload UserForm1
Me.Show

I select a worksheet name from the ComboBox, which executes
Private Sub ComboBox1_Change()
wkb.Worksheets(ComboBox1.Text).Visible = xlSheetVisible
wkb.Worksheets("Splash").Visible = xlSheetHidden
Unload Me
End Sub

I thought that at this point, I would be left with no code running and
looking at a worksheet. What happens, though, is that I error, and
the Debug option takes me all the way back to the UserForm1 button
code
Load UserForm2
as the bad line.

But that line was successfully executed - UserForm2 did appear and do
its thing.

How do I stop this?

Ed