Here is the whole code.
Option Explicit
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("PartsData")
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
If Trim(Me.txtwonumber.Value) = "" Then
Me.txtwonumber.SetFocus
MsgBox "Please enter a Work Order Number"
Exit Sub
End If
If Trim(Me.txtpnumber.Value) = "" Then
Me.txtpnumber.SetFocus
MsgBox "Please enter a Part Number"
Exit Sub
End If
If Trim(Me.txtsnumber.Value) = "" Then
Me.txtsnumber.SetFocus
MsgBox "Please enter a Serial Number"
Exit Sub
End If
If Trim(Me.txtheatcode.Value) = "" Then
MsgBox "Please enter a Heat Code"
If Application.CountIf(Sheets("PartsData").Range("D2:D999"), Trim(Me.txtheatcode.Value)) Then
MsgBox "Duplicate Heat Code Found"
Me.txtheatcode.SetFocus
Exit Sub
End If
End If
With ws
.Cells(iRow, 1).Value = Me.txtwonumber.Value
.Cells(iRow, 2).Value = Me.txtpnumber.Value
.Cells(iRow, 3).Value = Me.txtsnumber.Value
.Cells(iRow, 4).Value = Me.txtheatcode.Value
.Cells(iRow, 5).Value = Me.txtdescription.Value
End With
If CheckBox1.Value = True Then Me.txtAFdate.Value = Format(Date, "Medium Date")
If CheckBox1.Value = False Then Me.txtAFdate.Value = ""
If CheckBox2.Value = True Then Me.txtSPdate.Value = Format(Date, "Medium Date")
If CheckBox2.Value = False Then Me.txtSPdate.Value = ""
If CheckBox3.Value = True Then Me.txtMPdate.Value = Format(Date, "Medium Date")
If CheckBox3.Value = False Then Me.txtMPdate.Value = ""
If CheckBox4.Value = True Then Me.txtPdate.Value = Format(Date, "Medium Date")
If CheckBox4.Value = False Then Me.txtPdate.Value = ""
With ws
.Cells(iRow, 6).Value = Me.txtAFdate.Value
.Cells(iRow, 7).Value = Me.txtSPdate.Value
.Cells(iRow, 8).Value = Me.txtMPdate.Value
.Cells(iRow, 9).Value = Me.txtPdate.Value
End With
Me.txtwonumber.Value = ""
Me.txtpnumber.Value = ""
Me.txtsnumber.Value = ""
Me.txtheatcode.Value = ""
Me.txtwonumber.SetFocus
End Sub