+ Reply to Thread
Results 1 to 12 of 12

Object required error on CommandButton Click

  1. #1
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Object required error on CommandButton Click

    I have a CommanButton on a sheet that simply opens a UserForm, but I get a Run-time error 424.....Object required error. Can anyone tell me how to fix. I'm new to VBA. See code:
    Please Login or Register  to view this content.
    Last edited by rkjudy; 01-09-2011 at 06:28 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Object required error on CommandButton Click

    Nothing looks wrong there. Are you sure the name is correct?
    HTH
    Regards, Jeff

  3. #3
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Object required error on CommandButton Click

    I don't understand. The form name is correct. Could if be something to do with the properties of the form or the command button? Is there a missing object or something missing in Tools>References? This did work before. I did install the Analysis Toolpack add-in. It slowed down my workbook so much, I uninstalled it. Could this have done something?

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Object required error on CommandButton Click

    Is it possible to attach the workbook?

  5. #5
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Object required error on CommandButton Click

    It's probably something simple. Here's the workbook. Thanks, in advance for your help.
    Attached Files Attached Files

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Object required error on CommandButton Click

    Hello rkjudy,

    Well I sure can't see any reason for this not to work. Hopefullly one of the other members or a Forum moderator will help.

    On an aside and still being a rookie, it seems you could just use a regular forms button for a click type procedure versus the active x. Not entirely sure the difference. Guess I need to do some reading.

    Also, the slowness could be from the way you have your code. It appears you must have used the macro recorder to get most of your code. There is no need to use all of the Select/Selection.

    If you don't mind I will clean some of it up and send you a sample. In the meantime hopefully somebody will come to our rescue.

  7. #7
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Object required error on CommandButton Click

    Thanks for trying. I'm newer to VBA than most. That's why my code is so sloppy. I'll take any advise you can give. BTW, your only seeing a couple of the sheets, the entire workbook has about 12 sheets. Only the ones pertaining to my problem were in the example. Thanks again.

  8. #8
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Object required error on CommandButton Click

    I tried entering the .Show command to a macro and I still get the same error. Any ideas?

  9. #9
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Object required error on CommandButton Click

    Hello rkjudy,

    Okay, figured out not neccesarily where your problem is; however, I know where the error is coming from.

    Go to the VBE and the right click on the frmOrderEntryInfo. Select view code and then temporarily disable all the code.

    Now go back to the worksheet and press the CommandButton1. This worked for me so it's telling me you have to clean up, or actually finish whatever code you have behind the frm.

    Here is what I found:
    Goto Tools>Options... and select Break On All Errors on the General tab.

    Now if there is a problem in the initialize event the debugger should go to the line of code causing the problem.

    Or create a break point (F9) on a line of code in the initialize event and then step through the code with F8.
    Last edited by jeffreybrown; 01-09-2011 at 04:44 PM.

  10. #10
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: Object required error on CommandButton Click

    Thanks so much. The code associated with the form was bogus. Not sure how it got there. Any suggestions or shortcuts for my workbook are appreciated.

  11. #11
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,953

    Re: Object required error on CommandButton Click

    Please Login or Register  to view this content.
    Ben Van Johnson

  12. #12
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Object required error on CommandButton Click

    Okay here are just a few tips which may help.

    First, declare all variables and to ensure this happens enable Option Explicit.
    Go to the VBE >> Alt + F11 >> Options >> Editor Tab >> Require Variable Declaration.

    Second, a little code clean up is necessary. You have a lot in there and it may take some considerable effort, but in the end the your spreadsheet will thank you.

    The basic premise; usually there is no need to select an object to work with it in VBA so you can drop most of the Select/Selection, it just slows down the overall speed. As you are recording code, whatever you do is recorded, just like when you scroll the mouse (ActiveWindow.SmallScroll Down:=-6). This part is not necessary and is one of the culprits to slowing overall performance.

    Some more reading Beyond the Macro Recorder.

    Now, for an example of how you can clean up what you have. If you add a blank sheet to your workbook and title that blank sheet Sheet1 you can run this test code. Open up the VBE and place this code in a module and then place your cursor on the routine. Using F8 you can step through the code and watch it work. This means, if you have a dual monitor setup you can step through the code as you watch it play out on the Excel worksheet.

    Here’s a webpage which can add to speeding up code .

    Last thing I'll say is indenting code is a very good habit. Not only does it make the code easier for you to follow, but when you ask somebody else to look at your code it will make it easier for them too. One of the links below is for identing code.

    Please Login or Register  to view this content.
    Also for the passwords…
    Please Login or Register  to view this content.

    http://www.excelforum.com/2078299-post14.html
    http://www.mrexcel.com/forum/showthread.php?t=339643
    http://www.mrexcel.com/forum/showthread.php?t=352116
    http://www.mrexcel.com/forum/showthread.php?t=517549

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1