+ Reply to Thread
Results 1 to 9 of 9

Vlookup function in userform

  1. #1
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Vlookup function in userform

    Hi guys,

    Just a newbie here in the forum. I stumbled upon this site in search for an answer from Excel (VBA) experts around the globe. Hope I get to find them here!

    My problem is the ever recurring error 1004 ("Unable to get the VLookup property of the worksheetfunction class") whenever I trigger the ComboBox1 in Userform1, Activities tab (I used multipage here).

    Here's the code:
    HTML Code: 
    Also attached is the "sanitized" sample workbook for reference (pardon me if you see my programming skill and structure a bit messy, still newbie here ).

    In addition, why does this file keep on popping with message "This workbook contains links to one or more external sources that could be unsafe."? How can I get rid of it?
    Hope you can help me with this. This functionality is very crucial in this workbook.
    Thanks in advance guys!!!

    sample workbook.xlsm

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Vlookup function in userform

    Why do you set the value of the combobox to be equal to ProdID whenever it is changed? Are you actually setting the value of ProdID anywhere? Perhaps you meant
    Please Login or Register  to view this content.
    It would also help if you added some data in the Projects sheet so we can check it's working!

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Vlookup function in userform

    Hi,

    I can't find ProdID anywhere in your procedure, do you mean

    Please Login or Register  to view this content.
    instead of

    Please Login or Register  to view this content.
    ?
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Vlookup function in userform

    if the vlookup fails the it will return that error.
    if you use the application function, rather than worksheetfunction, it will return an error without raising the error dialog. You can then test for returned error and handle appropriately.

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    09-27-2011
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    86

    Re: Vlookup function in userform

    Hi,

    You are not loading the values while initializing the form in the combo box drop.
    Hence the error.
    Use error handler - but in this case the resultant output may be the input for the next one.
    However see the below updated code for the same but revise once before applying.
    Please Login or Register  to view this content.
    On the point 2 - "This workbook contains links to one or more external sources that could be unsafe."?
    There exists a external link in the workbook - break the link and save - it will work fine.

    regards,
    lokicl

  6. #6
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Re: Vlookup function in userform

    Wow! You guys really rock! Let me absorb first your comments and will get back to you with the result.

    Thanks for the prompt responses!

  7. #7
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Re: Vlookup function in userform

    Hi again experts, and thanks from your responses!

    I applied your workarounds and still cant get the preferred results. Ok here's the idea: if you look at the Userform1, on the Activities multipage tab, the Project ID combo box gets the RowSource from Projects sheet. Same behavior with Project Name combo box next to it. Upon triggering either combo boxes, the vlookup function should take effect, and values have to be reflecting in Start Date and End Date textbox (which are disabled to prevent manual manipulation) and even in themselves (Project ID and Project Name combo boxes). All these inputs actually came from the Projects tab (in userform) and Projects sheet.

    I am attaching again the file with sample inputs in Projects sheet for you guys to have a firm grip on the idea on how this macro should behave.
    application behavior.jpg

    I am also attaching the screen shot of how the application should behave on change event of either combo boxes.
    sample workbook.xlsm

    Again million thanks!

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Vlookup function in userform

    Try this
    Please Login or Register  to view this content.
    and I would incorporate Andy's point.

  9. #9
    Forum Contributor
    Join Date
    08-29-2012
    Location
    Manila, Philippines
    MS-Off Ver
    2019
    Posts
    102

    Re: Vlookup function in userform

    Thanks guys for all your inputs. I tried all your suggestions, however they do not return the preferred result. Due to time constraints, I ended up restructuring the user interface of the form and now out of this showstopper. I am no longer be needing this functionality, however for the sake of other forum visitors who are encountering the same predicament, I am not going to tag this as "solved", so that more solutions will surface here.

    Thanks a lot guys, and I believe I will be a frequent visitor of this forum from hereon.

+ 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. [SOLVED] vba: VLookUp Function in one userform
    By saikong051 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-14-2014, 02:02 PM
  2. Can't use If function with Vlookup in userform
    By tantcu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-09-2013, 06:01 PM
  3. Vlookup and Match function [vba--userform]
    By feixiiin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2013, 10:35 PM
  4. Userform Search Function Autofilter Results and Repopulate Userform
    By cindy71 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-16-2012, 03:46 PM
  5. [SOLVED] Userform Find (VLOOKUP) function search string problem
    By TalResha in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2011, 04:14 AM

Tags for this Thread

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