View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
moon[_5_] moon[_5_] is offline
external usenet poster
 
Posts: 40
Default User Form with CheckBoxes


Application.EnableEvents can not be used for UserForms or for controls in a
Worksheet.
However, with or without events - when I test it, your code works quite well
anyway.


What if you try the same thing this way...

Private Sub OKButton_Click()
Dim wb As Workbook, cs As Worksheet
Set wb = ThisWorkbook
Set cs = wb.Sheets("MMS for CS")
cs.Activate
If Me.CheckBoxClearCS.Value = True Then
cs.Cells(3, 15).Delete 'Same as Range("O3")
ElseIf Me.CheckBoxClearCS.Value = False Then
MsgBox "Not checked", vbInformation, "MSS for CS"
cs.Cells(1, 1).Select
End If
Set cs = Nothing
Set wb = Nothing
Unload Me
End Sub






"Paige" schreef in bericht
...
Can someone advise why this doesn't work; the userform (AskReClearData)
shows
up okay, but when I check the 'CheckBoxClearCS' within the form (done in a
frame via the Control Toolbox) and then hit ok, the code essentially skips
the 5th line (re clear contents). If the checkbox is NOT selected and I
hit
OK, then the code runs correctly.

Private Sub OKButton_Click()
Application.EnableEvents = True
If CheckBoxClearCS.Value = True Then
Worksheets("MMS for CS").Activate
Range("O3").ClearContents
Else
MsgBox ("Not checked")
Worksheets("MMS for CS").Activate
Range("A1").Select
End If
CheckBoxClearCS.Value = 0
AskReClearData.Hide
End Sub