我已经解决了 Private Sub CommandButton1_Click() Dim i As Long For i = 1 To 2 If Me.Controls("TextBox" & i).Text = "" Then MsgBox Me.Controls("Label" & i).Caption & "不得为空!": Exit Sub Next i If TextBox4.Text = "" Then MsgBox "单价不得为空!": Exit Sub i = Application.WorksheetFunction.CountA(Columns("a:a")) + 2 Cells(i, 1) = Format(TextBox1.Text, "0") Cells(i, 2) = TextBox2 Cells(i, 3) = TextBox3 Cells(i, 4) = Format(TextBox4.Text, "0.00") & "元" Cells(i, 5) = TextBox5 Cells(i, 6) = TextBox6 Cells(i, 7) = Format(DTPicker1.Value, "yyyy-mm-dd") Cells(i, 8) = TextBox8 TextBox1 = TextBox1 + 1 TextBox2 = TextBox2 TextBox3 = TextBox3 TextBox4 = "" TextBox5 = TextBox5 TextBox6 = TextBox6 TextBox8 = "" 'TextBox7 = "" End Sub 红色部分我是另外添加的,这样只要不关闭窗体,就会连续上次输入的数据了 |