![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi-
I designed a project with about 24 userforms. Most of them assign a value to a spreadsheet. The others are for the purpose of selecting a choice to show another userform(By way of a module). Im using optionbutton controlls for these few. Heres the code for one of them: Sub CommandButton3_Click() 'On Error Resume Next If OptionButton1.Value = True Then Me.Hide If OptionButton1.Value = True Then Call Module1.sheet1 'On Error GoTo 0 'On Error Resume Next If OptionButton2.Value = True Then Me.Hide If OptionButton2.Value = True Then Call Module1.sheet2 'On Error GoTo 0 'On Error Resume Next If OptionButton3.Value = True Then Me.Hide If OptionButton3.Value = True Then Call Module1.sheet3 'On Error GoTo 0 'On Error Resume Next If OptionButton4.Value = True Then Me.Hide If OptionButton4.Value = True Then Call Module1.sheet4 'On Error GoTo 0 Unload Me End Sub Heres the problem- when a certian sequence of userforms are promped to be shown or unloaded, the userforms with the optionbuttons hid and unload initialy, but come back (show) at some other point! If I dont use the error method, I get an error during the sequence, using the error method, the form just reappears. Ive tried everthing to pinpoint the problem. I replaced the optionbutton with a commandbutton to see the results and it works as it should. When I went back to using the optionbutton, I got an error. Im convinced its the way I wrote the code for the optionbuttons, but im not sure how to correct it- please help?? |
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,065
|
Hi
Try: Unload MyUserForm try after each not just at end so will act as kill.
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
Still doesnt work.
Sub CommandButton3_Click() Me.Hide 'On Error Resume Next 'If OptionButton1.Value = True Then Me.Hide If OptionButton1.Value = True Then Call Module1.sheet1 Unload Me 'On Error GoTo 0 'On Error Resume Next 'If OptionButton2.Value = True Then Me.Hide If OptionButton2.Value = True Then Call Module1.sheet2 Unload Me 'On Error GoTo 0 'On Error Resume Next 'If OptionButton3.Value = True Then Me.Hide If OptionButton3.Value = True Then Call Module1.sheet3 Unload Me 'On Error GoTo 0 'On Error Resume Next 'If OptionButton4.Value = True Then Me.Hide If OptionButton4.Value = True Then Call Module1.sheet4 Unload Me 'On Error GoTo 0 Unload Me End Sub Any other sugestions????? |
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|