السلام عليكم
إستبدل كود زر الحفظ في البورم بهذا
Private Sub CommandButton1_Click()
Dim iRow As Long, Cl As Range, Abu_Ahmed As Boolean
Dim ws As Worksheet
T = [B10000].End(xlUp).Row
Set ws = Worksheets("ورقة1")
iRow = ws.Cells(Rows.Count, 2) _
.End(xlUp).Offset(1, 0).Row
'==================================================================================
For Each Cl In Range("B2:B" & [B10000].End(xlUp).Row)
If Cl = Me.TextBox2.Value Then
If Cl.Offset(0, 1) = Me.TextBox3.Value And Cl.Offset(0, 2) = Me.TextBox4.Value And _
Cl.Offset(0, 3) = Val(Me.TextBox5.Value) Then Abu_Ahmed = True: GoTo 1
End If
Next
1 If Abu_Ahmed Then
MsgBox "البيانات موجودة مسبقاً": GoTo 2
Else
ws.Cells(iRow, 2).Value = Me.TextBox2.Value
ws.Cells(iRow, 3).Value = Me.TextBox3.Value
ws.Cells(iRow, 4).Value = Me.TextBox4.Value
ws.Cells(iRow, 5).Value = Me.TextBox5.Value
End If
'=====================================================================================
Me.TextBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox4.Value = ""
Me.TextBox5.Value = ""
Me.TextBox2.SetFocus
2 End Sub