+ Reply to Thread
Results 1 to 15 of 15

Vlookup on Userform

  1. #1
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Vlookup on Userform

    Hi all,

    I can't see what is wrong with my code:

    MyRange is a two column table on Sheet1 (an actual XL table). I have it firing as a 'Userform_initialize' event if that matters?

    Please Login or Register  to view this content.

  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: Vlookup on Userform

    What is wrong with the code?

    Are you getting errors? Incorrect results?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    Hi Norie,

    Apologies, that was an oversight. I receive the RTE 1004 (application/object undefined error).

    On the whole line...

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    How can your combobox have a value when the form is being loaded?

    What's MyRange - the address of a range or a Range object?
    Anyone who confuses correlation and causation ends up dead.

  5. #5
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    That's true. I never thought of that. MyRange is reference to an Excel Table (excluding the headers).

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    If it's a Range object, then you just use:
    Please Login or Register  to view this content.
    but of course that won't fix the other issue.

  7. #7
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    I see. Thanks romper - I'll sort the other issue out. I'll connect it to a Multipage_change event or something.

  8. #8
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    You could have other code in the Initialize event to assign a value to the combobox - just depends what you're trying to achieve.

  9. #9
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    What I am trying to do is:
    • User selects a value from a ComboBox1
    • Textbox1 is populated according to vLU based upon value in CB1


    I tried assigning it to ComboBox1_Change() event but I got a RTE13 'Type error mismatch'

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    That probably means the value isn't being found - what kind of data is it - numeric/date/text?

  11. #11
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    Alphanumreric.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    Can you post a sample workbook?

  13. #13
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    Here you go Romper (thanks for your help).
    Attached Files Attached Files

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    MyTable is the name of your table, not a Range object, so you need:
    Please Login or Register  to view this content.
    BTW you can call me Rory, rather than Romper.

  15. #15
    Forum Contributor
    Join Date
    08-23-2011
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    404

    Re: Vlookup on Userform

    Hi Rory,

    Excellent! Thank you very much. It makes perfect sense.

    BTW sorry for the lateness of my reply. I never received the auto-email stating there was a reply!

    Thank you very much.

  16. #16
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,309

    Re: Vlookup on Userform

    No worries - glad to help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. help with vlookup in userform
    By emymeeky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-28-2014, 04:14 PM
  2. VLOOKUP in userform
    By Hond70 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-25-2011, 07:32 AM
  3. Using vLookup from Userform
    By bstubbs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-18-2011, 10:54 AM
  4. VLookup In UserForm
    By shudder in forum Excel General
    Replies: 3
    Last Post: 12-12-2009, 09:24 PM
  5. Using VLOOKUP In A UserForm
    By SamuelT in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-11-2008, 07:42 AM

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