The error is because you have two initialize events which is not allowed. You need to delete the original code for the event.
It`s not working.
Below the codes for command button 1 ( enter data , clear ) and cmd button 2 ( clear form ) :
Private Sub CommandButton1_Click()
Worksheets("Sheet1").Unprotect
Dim RowCount As Long
Dim ctl As Control
' Check user input
If Me.TextBox1.Value = "" Then
MsgBox "Please enter a Nr Crt.", vbExclamation, "Staff Expenses"
Me.TextBox1.SetFocus
Exit Sub
End If
If Me.TextBox2.Value = "" Then
MsgBox "Please enter a Data.", vbExclamation, "Staff Expenses"
Me.TextBox2.SetFocus
Exit Sub
End If
If Me.ComboBox1.Value = "" Then
MsgBox "Please choose a Document.", vbExclamation, "Staff Expenses"
Me.ComboBox1.SetFocus
Exit Sub
End If
If Me.TextBox3.Value = "" Then
MsgBox "Please enter a Comerciant.", vbExclamation, "Staff Expenses"
Me.TextBox3.SetFocus
Exit Sub
End If
If Me.TextBox4.Value = "" Then
MsgBox "Please enter a Alte detalii.", vbExclamation, "Staff Expenses"
Me.TextBox4.SetFocus
Exit Sub
End If
' Write data to worksheet
RowCount = Worksheets("Sheet1").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Sheet1").Range("A1")
.Offset(RowCount, 0).Value = Me.TextBox1.Value
.Offset(RowCount, 1).Value = Me.TextBox2.Value
.Offset(RowCount, 2).Value = Me.ComboBox1.Value
.Offset(RowCount, 3).Value = Me.TextBox3.Value
.Offset(RowCount, 4).Value = Me.TextBox4.Value
End With
' Clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
ElseIf TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl
Worksheets("Sheet1").Protect
End Sub
Private Sub CommandButton2_Click()
' Clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
ElseIf TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl
End Sub