Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run-time Error 424 Object Required UserForm doesnt exist

Tags:

excel

vba

I'm attempting to do the things written on this site www.excel-easy.com but when I click the commandbutton (from ActiveX controls) in the worksheet just like what the website instructed, nothing happens. I tried to use a button from form controls, but it says that the error is in this ---> DinnerPlannerUserForm.Show

My Code:

Sub Button2_Click()
    DinnerPlannerUserForm.Show
End Sub

When I used F8, it said the error is here --> Private Sub UserForm_Initialize()

Private Sub UserForm_Initialize()

    'Empty NameTextBox
    NameTextBox.Value = ""

    'Empty PhoneTextBox
    PhoneTextBox.Value = ""

    'Empty CityListBox
    CityListBox.Clear

    'Fill CityListBox
    With CityListBox
        .AddItem "San Francisco"
        .AddItem "Oakland"
        .AddItem "Richmond"
    End With

    'Empty DinnerComboBox
    DinnerComboBox.Clear

    'Fill DinnerComboBox
    With DinnerComboBox
        .AddItem "Italian"
        .AddItem "Chinese"
        .AddItem "Frites and Meat"
    End With

    'Uncheck DataCheckBoxes
    DateCheckBox1.Value = False
    DateCheckBox2.Value = False
    DateCheckBox3.Value = False

    'Set no car as default
    CarOptionButton2.Value = True

    'Empty MoneyTextBox
    MoneyTextBox.Value = ""

    'Set Focus on NameTextBox
    NameTextBox.SetFocus

End Sub
like image 292
VBAJam Avatar asked Jul 11 '15 00:07

VBAJam


People also ask

What is run time error 424 in VBA?

In rare cases, this error occurs when you have a valid object but are attempting to perform an invalid action on the object. For example, you may receive this error if you try to assign a value to a read-only property. Check the object's documentation and make sure the action you are trying to perform is valid.

What is object required error in VBA?

Object Required in Excel VBA. Object required is an error which is caused at run time when we have defined any variable which is not an object but we try to assign some values using a SET statement. This error is a run time error that arises for various reasons.


2 Answers

This error can also occur when you remove or delete a textbox from your form, but forget to remove it from a line in initialization for eg:

Private Sub UserForm_Initialize()
    CommandButton2.Enabled = False
    TextBox4.Enabled = False    'textbox deleted from form
End sub
like image 160
Bart Avatar answered Sep 25 '22 01:09

Bart


I'm assuming this issue has been resolved, but for anyone just now looking at it. I had this issue and it turned out to be that I had removed a ComboBox from my form, but it was still referenced in the code. Once I removed that section of the code, it worked beautifully.

like image 36
Stephanie Avatar answered Sep 26 '22 01:09

Stephanie