+ Reply to Thread
Results 1 to 15 of 15

VBA - Compile Error - Wrong number of arguments

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    cardiff
    MS-Off Ver
    Excel 2003
    Posts
    51

    VBA - Compile Error - Wrong number of arguments

    Hi Guys

    I have created a UserForm to add data to which is working fine.

    I have added a search button to search for the data and pull it back to the UserForm I have created but am getting the following
    error
    ---------------------------
    Microsoft Visual Basic
    ---------------------------
    Compile error:

    Wrong number of arguments or invalid property assignment
    ---------------------------
    OK Help
    ---------------------------


    Please find below the code I have so far

    Please Login or Register  to view this content.
    Thanks for your help

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA - Compile Error - Wrong number of arguments

    Where do you get the error?
    If posting code please use code tags, see here.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: VBA - Compile Error - Wrong number of arguments

    I suspect that is your message boxes:

    Please Login or Register  to view this content.

    Lose some brackets:

    Please Login or Register  to view this content.

    Check if there are any others.


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    04-24-2013
    Location
    cardiff
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: VBA - Compile Error - Wrong number of arguments

    Hi

    Getting the message around
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA - Compile Error - Wrong number of arguments

    You've one too many arguments, you are using x1 instead of xl and some of the arguments are out of place.

    If you only want to specify certain arguments use there names.

    I think it should be something like this but you'd better check.
    Please Login or Register  to view this content.
    PS You should probably check the MsgBox code too as TMShucks suggested, that was actually my first thought on where the problem was.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: VBA - Compile Error - Wrong number of arguments

    Looks like find takes 9 parameters. You have 10.

    http://msdn.microsoft.com/en-us/libr.../ff839746.aspx


    expression .Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection, MatchCase, MatchByte, SearchFormat)



    Regards, TMS

  7. #7
    Registered User
    Join Date
    04-24-2013
    Location
    cardiff
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: VBA - Compile Error - Wrong number of arguments

    Thanks Guys

    Getting a Runtime error 424

    line highlighted in Yellow is
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    04-24-2013
    Location
    cardiff
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: VBA - Compile Error - Wrong number of arguments

    Please find Sample workbook

    maybe easier to resolve Issue

    I want to search by CRN number and it pulls all the other information back to Userform excluding the Timestamp
    Attached Files Attached Files
    Last edited by Janto724; 06-27-2013 at 11:20 AM.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: VBA - Compile Error - Wrong number of arguments

    What's in TextBox1?

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA - Compile Error - Wrong number of arguments

    There isn't a control called Textbox1.

    You have txtHouse, txtCRN etc for your textboxes on the userform.

    So I suppose the line should be this.
    Please Login or Register  to view this content.

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA - Compile Error - Wrong number of arguments

    Hello Janto724,

    I made some modifications to your workbook. The results are now displayed in a ListBox. Have a look and let me know what you think about the changes.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  12. #12
    Registered User
    Join Date
    04-24-2013
    Location
    cardiff
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: VBA - Compile Error - Wrong number of arguments

    Hi Leith

    Thanks for your help and amendments to the code

    Works great

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA - Compile Error - Wrong number of arguments

    Can I just check?

    Were the suggestions I made of any use?

  14. #14
    Registered User
    Join Date
    04-24-2013
    Location
    cardiff
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: VBA - Compile Error - Wrong number of arguments

    Hi Norie

    The suggest you made were of use it looks as though when I created the user form I needed to add description box for all the inforamtion to feedback into. I would have preferred the data to fall back into each individual text box.

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA - Compile Error - Wrong number of arguments

    Sorry, you've kind of lost me there.

    As far as I can see there was nothing wrong with the userform, the code just needed a few tweaks.

+ 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