PDA

View Full Version : Solved: UserForm Checkboxes



LLL
02-19-2009, 11:09 AM
I previously had help from mdmackillop with getting my user forms to save the inputed data. I have 6 userforms. The first form i have no trouble with. I am trying now to create the code for the remaining forms. I have started form 2 and am running into trouble. I have attached file. Can anyone assist?:dunno

Bob Phillips
02-19-2009, 11:20 AM
What are we supposed to do with that? You want us to break it all down, work out what it should be doing, without any clues, and then work out how to do it.

LLL
02-19-2009, 11:30 AM
:blush Ok, well i am just wandering why my Userform2 is not responding to the following formulas
Dim r As Range
Dim t As Range

Private Sub UserForm2_Initialize()
Application.EnableEvents = False
Set r = ActiveCell
For i = 1 To 5
If r.Offset(, 64 + i) <> "" Then
Me.Controls("Checkbox" & i) = True
End If
Next
Application.EnableEvents = True
End Sub
Private Sub CheckBox1_AfterUpdate()
Set t = Cells(r.Row, 92)
If Me.CheckBox1 = True Then
If t = "" Then t = "x"
Else
t.ClearContents
End If
End Sub

Private Sub CheckBox2_AfterUpdate()
Set t = Cells(r.Row, 93)
If Me.CheckBox2 = True Then
If t = "" Then t = "x"
Else
t.ClearContents
End If
End Sub
Private Sub CheckBox3_AfterUpdate()
Set t = Cells(r.Row, 94)
If Me.CheckBox3 = True Then
If t = "" Then t = "x"
Else
t.ClearContents
End If
End Sub
Private Sub CheckBox4_AfterUpdate()
Set t = Cells(r.Row, 95)
If Me.CheckBox4 = True Then
If t = "" Then t = "x"
Else
t.ClearContents
End If
End Sub
Private Sub CheckBox5_AfterUpdate()
Set t = Cells(r.Row, 96)
If Me.CheckBox5 = True Then
If t = "" Then t = "x"
Else
t.ClearContents
End If
End Sub

Private Sub UserForm_Click()
End Sub

mdmackillop
02-19-2009, 01:01 PM
As mentioned in the other thread

Private Sub UserForm2_Initialize()

should be

Private Sub UserForm_Initialize()

GTO
02-19-2009, 01:15 PM
Greetings,

Unless you don't want the user to be able to get the normal results (entering edit mode) of double-clicking in ANY column - you may want to rid the first 'Cancel'.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Get rid of this---> Cancel = True
Select Case Target.Column
Case 12
Cancel = True
UserForm1.Show
Case 13
'...etc (statements)...

Hope this helps,

Mark