![]() |
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 |
Getting error with load/unload of UserForms??
I'd suggest that, instead of unloading UF1, you Hide it. Then try unloading
it after you unload UF2. -- Jim "Ed from AZ" wrote in message oups.com... 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 |
Getting error with load/unload of UserForms??
Hi, Jim. I changed both form codes to simply Hide the forms instead
of Unload them. Now my workbook works fine. I tried using the Deactivate event to unload the forms, but nothing seems to work, as far as I can tell - I had Stop statements in the codes that were supposed to unload the forms, but the code never got there. This brings up a couple of questions: (1) If the forms are hidden, is there any reason they _need_ to be Unloaded? Will the extra memory used by them hanging in there slow down my workbook? (2) Is there any way to detect if a form is still open but just hidden? Ed On Aug 21, 4:47 pm, "Jim Rech" wrote: I'd suggest that, instead of unloading UF1, you Hide it. Then try unloading it after you unload UF2. -- Jim "Ed from AZ" wrote in ooglegroups.com... 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- Hide quoted text - - Show quoted text - |
All times are GMT +1. The time now is 06:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com