I am working to create a form that automatically opens when the workbook opens. This form, once completed, should submit information onto a worksheet within the workbook. Everything works on the form correctly...data is inputted and when i click on submit it populates on the worksheet. The problem is whenever i add a second set of data in, the form replaces existing information on the worksheet. It will not drop down a row. I've included my code below. Please help!
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdSubmit_Click()
Dim RowCount As Long
Dim ctl As Control
If Me.txtYourName.Value = "" Then
MsgBox "Please enter your Name.", vbExclamation, "Sheet2"
Me.txtYourName.SetFocus
Exit Sub
End If
If Not IsDate(Me.BegDate.Value) Then
MsgBox "The Date box must contain a date.", vbExclamation, "Sheet2"
Me.BegDate.SetFocus
Exit Sub
End If
RowCount = Worksheets("Sheet2").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Sheet2").Range("A1").End(xlDown)
.Offset(RowCount, 0).Value = Me.txtFunct.Value
.Offset(RowCount, 1).Value = Me.cboDept.Value
.Offset(RowCount, 2).Value = Me.txtPosition.Value
.Offset(RowCount, 3).Value = Me.cboLocation
.Offset(RowCount, 4).Value = DateValue(Me.BegDate.Value)
.Offset(RowCount, 5).Value = DateValue(Me.EndDate.Value)
.Offset(RowCount, 6).Value = Me.BegTime.Value
.Offset(RowCount, 7).Value = Me.EndTime.Value
.Offset(RowCount, 8).Value = Me.txtYourName.Value
.Offset(RowCount, 9).Value = Me.txtTrainer.Value
.Offset(RowCount, 10).Value = Format(Now, "mm/dd/yyyy hh:nn:ss")
End With
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
Private Sub UserForm_Click()
End Sub