Private Sub CommandButton6_Click() On Error Resume Next Dim A As Range Set A = Sheets("信息").Columns(1).Find(TextBox1.Value) If Not A Is Nothing Then MsgBox "已存在该姓名记录" Exit Sub End If With Sheets("信息") x = .Range("A65536").End(xlUp).Row + 1 If TextBox1.Value <> "" And TextBox2.Value <> "" Then .Cells(x, 1) = Format(TextBox1.Value, "YYYY" & "年" & "MM" & "月" & "DD" & "日") .Cells(x, 2) = Format(TextBox2.Value, "0.00") ' TextBox1.Value = "" ' TextBox2.Value = "" MsgBox "部数据已录入!" Else MsgBox "请填写全部数据!" End If End With Me.TextBox1.Text = "" Me.TextBox2.Text = "" Me.TextBox3.Text = "" End Sub Private Sub CommandButton7_Click() Unload Me End Sub Private Sub CommandButton9_Click() C = Application.WorksheetFunction.Sum(Sheet2.Range("B2:B" & Sheet2.Range("a65536").End(xlUp).Row)) TextBox3.Text = Format(C, "0.00") End Sub Private Sub UserForm_Initialize() Me.TextBox1.Text = "" Me.TextBox2.Text = "" Me.TextBox3.Text = "" End Sub |