+ Reply to Thread
Results 1 to 4 of 4

VLookup In UserForm

  1. #1
    Registered User
    Join Date
    09-11-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    42

    VLookup In UserForm

    Hi Guys,

    I am undertaking my first Userform set-up after following several templates/guides available on the web, however I think I have jumped in the deep-end by creating such a big project.

    I have completed the form design, named all list/boxes etc and have done the majority of coding (at least I think so far). I am know having trouble getting some sort of VLookup to work within the Userform having tried various different codes.

    I have attached a slimmed down version of my project and would like the following

    cboReg - This it linked to a named range (column A4 down)
    txtMake - I would like this to be pulled through from cboReg selection (Make is in column B)


    If someone could get me started I will be able to transpose to the rest.

    If you spot any inherent errors please point them out, also I am planning on hiding all the sheets so users can only use this UserForm (I have some code for this already) if this has any bearing on any codes.

    Thanks in advance

    Stuart
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Re: VLookup In UserForm

    Hi

    Paste the following code into your form and it will populate the relevant fields when you select an item from the drop down list.

    Please Login or Register  to view this content.
    You can extend it to add as many as required.

    If you need anything else please let me know.

    Regards

    Jeff

  3. #3
    Registered User
    Join Date
    09-11-2009
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    42

    Re: VLookup In UserForm

    Cheers Jeff,

    I have added the additional coding to the rest of my requirements, however when I now try to use the cboReg for data input I get Run-Time Error '1004' an when I go into Debug it highlights this line:

    Please Login or Register  to view this content.
    This is the full code of what I have now:

    Please Login or Register  to view this content.
    Thanks

    Stuart

  4. #4
    Forum Contributor
    Join Date
    04-21-2007
    Location
    Lima, Peru
    MS-Off Ver
    2000, 2007, 2010
    Posts
    674

    Re: VLookup In UserForm

    Hi

    It sounds as though you do not have a value for drow, which would cause the error. When debugging place the cursor over the word drow and a popup will show the value, if it is zero then there was no match for the reg no., you can avoid this using an if statement to trap the error with a message box explaining why and then an exit sub statement to take you back to the form e.g.

    Please Login or Register  to view this content.
    If not then it would be useful to see a copy of the sheet to find out what is causing the error.

    regards


    Jeff

+ 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