gerald.lebret
New Member
- Joined
- Nov 4, 2011
- Messages
- 7
Hello,
I have designed a form with about 160 controls among about a third of checkboxes.
The purpose for the users is to be able to check several checkboxes and when they validate the form vba will create a new entry in an excel sheet.
I've written the following code but can't make it work.
Can anyone help?
I have designed a form with about 160 controls among about a third of checkboxes.
The purpose for the users is to be able to check several checkboxes and when they validate the form vba will create a new entry in an excel sheet.
I've written the following code but can't make it work.
Can anyone help?
Code:
Private Sub Update_Click()
Dim CBX As CheckBox
Dim LastRow As Long
Dim ctrl As Control
On Error GoTo ErrorHandle
LastRow = Worksheets("Rapport").Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(LastRow, 1).Select
For Each ctrl In Me.Controls
If TypeOf ctrl Is MSForms.CheckBox Then
If CheckBox.Value = True Then
ActiveCell.Value = CheckBox.Caption
End If
End If
Cells(LastRow, 1).Select
Next ctrl
ErrorHandle:
MsgBox Err.Description
End Sub