This code works for me before but when I tried to add 47 textboxes it show the erroe. RUN-TIME error 424 object required.
VBA Code:
Dim a, i As Byte, deg As String
Private Sub CommandButton1_Click()
Dim sonsat, lastrow As Long, ara As Range
If TextBoxC.Text = "" Or TextBoxJ.Text = "" Then
MsgBox "Incomplete Data", vbCritical, ""
TextBoxA.SetFocus 'error displayed here
Exit Sub
End If
lastrow = Sheets("Sheet1").Cells(Rows.Count, "B").End(xlUp).Row
sonsat = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row + 1
Set ara = Range("B2:B" & lastrow).Find(What:=TextBoxA.Text, LookIn:=xlValues, LookAt:=xlWhole) 'error displayed here
If Not ara Is Nothing Then
MsgBox "This name already exist ! Please try a different name", vbCritical, ""
TextBoxA.SetFocus
Exit Sub
End If
Cells(sonsat, 1) = sonsat - 1
Cells(sonsat, 2) = TextBoxA
Cells(sonsat, 3) = TextBoxB
Cells(sonsat, 4) = TextBoxC
Cells(sonsat, 5) = TextBoxD
Cells(sonsat, 6) = TextBoxE
Cells(sonsat, 7) = TextBoxF
Cells(sonsat, 8) = TextBoxG
Cells(sonsat, 9) = TextBoxH
Cells(sonsat, 10) = TextBoxI
Cells(sonsat, 11) = TextBoxJ