في هذه الحالة يصبح الكود كالتالي:
Private Sub CommandButton1_Click()
On Error GoTo Ali
Dim Itm As String
Dim FndItm As Range
If TextBox1 = "" Or TextBox2 = "" Then MsgBox "You have to fill out all fields", vbExclamation, "Blank Fields"
If OptionButton1 = False And OptionButton2 = False Then MsgBox "You have to choose the type of the activity", vbExclamation, "Activity Type"
TextBox1.SetFocus
With Columns(1)
Set FndItm = .Find(TextBox1)
End With
If Not FndItm Is Nothing Then
FndItm.Offset(0, 1).Select
[IV1] = Selection
Selection = [IV1] - TextBox2
If OptionButton1 Then Selection = [IV1] + TextBox2
If OptionButton2 Then Selection = [IV1] - TextBox2
[IV1].ClearContents
Unload Me
Else
Cells(Application.WorksheetFunction.CountA([A1:A65536]) + 1, 1) = TextBox1
Cells(Application.WorksheetFunction.CountA([B1:B65536]) + 1, 2) = TextBox2
Unload Me
End If
Ali:
If Err <> 0 Then End
End Sub
_______.rar