Private Sub 添加_Click()
If 编号.Text = "" Or 型号.Text = "" Then Exit Sub
Dim A As Range
Set A = Sheets("sheet2").Cells.Find(编号)
If Not A Is Nothing Then
MsgBox "已存在该编号记录"
Exit Sub
End If
''***********************************
On Error Resume Next
Dim X As Integer, Y As Integer
Dim Mrng As Range
With Sheets("sheet2")
Y = .Range("A65536").End(xlUp).Row + 1
For X = 1 To Me.Controls.Count
Set Mrng = .Cells.Find(Me.Controls(X).Name)
.Cells(Y, Mrng.Column) = Me.Controls(X).Text
Next X
End With
MsgBox "添加成功", 64
Set Mrng = Nothing
清空所有内容
End Sub