Results 1 to 3 of 3

TextBox VLookup N00B

Threaded View

  1. #1
    Registered User
    Join Date
    06-14-2013
    Location
    San Jose, CA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Question TextBox VLookup N00B

    Hi,

    I have a UserForm with. When One TextBox (TextBox2) is filled out, I want another TextBox (TextBox4) to autofill based on the results of a Vlookup. This is my first attempt at a "smarter" UserForm.

    In the UserForm(Code) window I changed the automatically generated control code for TextBox2 to the following:

    Private Sub TextBox2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    
     Me.TextBox4.Value = Application.VLookup(Me.TextBox2.Value, Worksheets("VendorData").Range("A:B"), 2, False)
    
    End Sub
    What is kind of driving me nuts is: If I change the ,range_lookup to TRUE for "approximate match" the code returns a value from the Vlookup... It is the WRONG value but it returns and populates TextBox4. When the code is run as above I get: Run-time error '-2147352571(80020005)': Could not set the Value property. Type Mismatch.

    Being new to UserForms, and knowing that I can make code *like* this work on a sheet I have been frustrated. Current file contains confidential information so I have not posted it. Worksheets("VendorData") column A is a unique Number I am searching for, Column B is the vendor's name that I want returned. I suspect it has something to do with ..._Exit(ByVal Cancel As MSForms.ReturnBoolean) because I truly do NOT understand what that is doing, other than waiting until the user exits the TextBox before running the code.

    Thanks in advance.
    Last edited by mhowden42; 06-17-2013 at 03:40 PM.

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