View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Robert Bruce[_2_] Robert Bruce[_2_] is offline
external usenet poster
 
Posts: 108
Default closng userform and canceling changes

Roedd <<John wedi ysgrifennu:

Hi Jacob,

I would split up the functionality a little cleanup code on each
button click event. So for example:

Private Sub UserForm_Initialize()
Call SetDefaultSettings
End Sub

Private Sub cmdOK_Click()
'Add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub cmdCancel_Click()
'Ignore add values to workbook code
Call SetDefaultSettings
Me.Hide
End Sub

Private Sub SetDefaultSettings()
Me.chkBox1.Value = False
'Plus other changes you want to make
End Sub


Or just call SetDefaultSettings from Userform_activate which will run every
time the form is unhidden.

Rob