How can I create a code to prompt the user when the date isn't entered as mm/dd/yyyy format? Also, how can I ensure that the user selects either the Prospect button or the Current button? Thank you. Here is my code:
Private Sub Label1_Click()
btnProspect.GroupName = "CustomerType"
btnCurrent.GroupName = "CustomerType"
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdEnter_Click()
ActiveSheet.Unprotect Password:="fscbcall"
Dim RowCount As Long
Dim benefits, total As Single
' Write data to worksheet
RowCount = Worksheets("Current Month").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Current Month").Range("A1")
.Offset(RowCount, 0).Value = Me.txtInitials.Value
.Offset(RowCount, 1).Value = Me.txtName.Value
.Offset(RowCount, 2).Value = Me.btnProspect.Value
.Offset(RowCount, 2).Value = Me.btnCurrent.Value
.Offset(RowCount, 3).Value = Me.txtDate.Value
.Offset(RowCount, 4).Value = Me.chkTop.Value
.Offset(RowCount, 5).Value = Me.txtRemarks.Value
.Offset(RowCount, 6).Value = Me.txtFollowupdt.Value
.Offset(RowCount, 7).Value = Me.txtFollowupcmt.Value
If Me.chkTop.Value = True Then
.Offset(RowCount, 4).Value = "Yes"
Else
.Offset(RowCount, 4).Value = "No"
End If
If btnCurrent.Value = True Then
.Offset(RowCount, 2) = "Current"
ElseIf btnProspect.Value = True Then
.Offset(RowCount, 2) = "Prospect"
End If
End With
'Clear the form
Unload Me
With Worksheets("Current Month")
With .Range("A7:H200")
.Sort Key1:=.Columns("A"), Order1:=xlAscending, Key2:=.Columns("D"), Order2:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
ActiveSheet.Protect Password:="fscbcall", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
End With
End Sub
Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not txtDate.Value Like "##[/]##[/]####" Then
MsgBox "Must Be Format mm/dd/yyyy"
Textbox1.SetFocus
Cancel = True
Textbox1.Value = ""
Else: chkTop.Value
End If
End Sub
Private Sub txtRemarks_Change()
End Sub
Private Sub UserForm_Click()
End Sub
Private Sub Label1_Click()
btnProspect.GroupName = "CustomerType"
btnCurrent.GroupName = "CustomerType"
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdEnter_Click()
ActiveSheet.Unprotect Password:="fscbcall"
Dim RowCount As Long
Dim benefits, total As Single
' Write data to worksheet
RowCount = Worksheets("Current Month").Range("A1").CurrentRegion.Rows.Count
With Worksheets("Current Month").Range("A1")
.Offset(RowCount, 0).Value = Me.txtInitials.Value
.Offset(RowCount, 1).Value = Me.txtName.Value
.Offset(RowCount, 2).Value = Me.btnProspect.Value
.Offset(RowCount, 2).Value = Me.btnCurrent.Value
.Offset(RowCount, 3).Value = Me.txtDate.Value
.Offset(RowCount, 4).Value = Me.chkTop.Value
.Offset(RowCount, 5).Value = Me.txtRemarks.Value
.Offset(RowCount, 6).Value = Me.txtFollowupdt.Value
.Offset(RowCount, 7).Value = Me.txtFollowupcmt.Value
If Me.chkTop.Value = True Then
.Offset(RowCount, 4).Value = "Yes"
Else
.Offset(RowCount, 4).Value = "No"
End If
If btnCurrent.Value = True Then
.Offset(RowCount, 2) = "Current"
ElseIf btnProspect.Value = True Then
.Offset(RowCount, 2) = "Prospect"
End If
End With
'Clear the form
Unload Me
With Worksheets("Current Month")
With .Range("A7:H200")
.Sort Key1:=.Columns("A"), Order1:=xlAscending, Key2:=.Columns("D"), Order2:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
ActiveSheet.Protect Password:="fscbcall", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
End With
End Sub
Private Sub Textbox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not txtDate.Value Like "##[/]##[/]####" Then
MsgBox "Must Be Format mm/dd/yyyy"
Textbox1.SetFocus
Cancel = True
Textbox1.Value = ""
Else: chkTop.Value
End If
End Sub
Private Sub txtRemarks_Change()
End Sub
Private Sub UserForm_Click()
End Sub