A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
You clear all the check boxes in TextBox9_AfterUpdate, including TextBox9 itself.
This causes TextBox9_AfterUpdate to run again, but then the line
m = TextBox10.Value
fails since TextBox10 does not contain a date: it has just been cleared. To avoid this problem:
Private Sub TextBox9_AfterUpdate()
Dim m As Date
Dim n As Date
Dim a, b, c, diff As Integer
Dim erow As Long
Static f As Boolean
If f Then Exit Sub
a = Me.TextBox3.Value
b = Me.TextBox4.Value
m = Me.TextBox10.Value
n = Me.TextBox9.Value
diff = DateDiff("d", m, n)
Me.TextBox11.Value = (diff + 1)
c = Me.TextBox11.Value
Me.TextBox6.Value = (c * a * b)
erow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1) = Me.TextBox1.Text
Cells(erow, 2) = Me.TextBox7.Text
Cells(erow, 3) = Me.TextBox3.Text
Cells(erow, 4) = Me.TextBox4.Text
Cells(erow, 5) = Me.TextBox10.Value
Cells(erow, 6) = Me.TextBox9.Value
Cells(erow, 7) = Me.TextBox11.Value
Cells(erow, 8) = Me.TextBox5.Text
Cells(erow, 9) = Me.TextBox6.Value
f = True
Me.TextBox1.Text = ""
Me.TextBox7.Text = ""
Me.TextBox11.Text = ""
Me.TextBox3.Text = ""
Me.TextBox4.Text = ""
Me.TextBox9.Value = ""
Me.TextBox10.Value = ""
Me.TextBox5.Text = ""
Me.TextBox6.Text = ""
Me.TextBox7.SetFocus
Me.TextBox1.Value = Sheet1.Range("a1").CurrentRegion.Rows.Count
f = False
End Sub