السلام عليكم
ضع ترويسة في الورقة Anas
وضع صف به بيانات
واليك التعديل على زري الخطاء
Private Sub CommandButton3_Click()
'زر حذف
Application.ScreenUpdating = False
For i = 1 To 100
If Val(TextBox1.Text) = Cells(i, 1) Then
rr = Cells(i, 1).Row
If rr = 1 Then Exit Sub
Cells(i, 1).EntireRow.Delete shift:=xlUp
TextBox1.Text = Cells(rr - 1, 1)
TextBox2.Text = Cells(rr - 1, 2)
TextBox3.Text = Cells(rr - 1, 3)
TextBox4.Text = Cells(rr - 1, 4)
TextBox5.Text = Cells(rr - 1, 5)
End If
Next i
Application.ScreenUpdating = True
TextBox1.SetFocus
End Sub
Private Sub CommandButton4_Click()
'زر اضافة
'هذا هو الخطأ bb = Range("a" & r).Offset(1, 0).Select
Sheets("Anas").Activate
For i = 2 To 1000
If Cells(i, 2) <> "" Then
Cells(i, 1) = i - 1
End If
Next
r = [a1000].End(xlUp).Row
bb = Range("a" & r).Offset(1, 0).Select
ActiveCell = Cells(r, 1).Value + 1
TextBox1.Text = Cells(ActiveCell.Row, 1)
Cells(ActiveCell.Row, 2) = TextBox2.Text
Cells(ActiveCell.Row, 3) = Val(TextBox3.Text)
Cells(ActiveCell.Row, 4) = TextBox4.Text
Cells(ActiveCell.Row, 5) = TextBox5.Text
TextBox1.SetFocus
End Sub