RUN-TIME ERROR '424': OBJECT REQUIRED

yakult014

New Member
Joined
Apr 13, 2020
Messages
12
Office Version
  1. 2010
Platform
  1. Windows
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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I
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
Hoping that there's an answer new at VBA EXCEL
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,207
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top