+ Reply to Thread
Results 1 to 13 of 13

I have a userform and I want one of the text boxes to be populatated using vlookup

  1. #1
    Registered User
    Join Date
    11-26-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    I have a userform and I want one of the text boxes to be populatated using vlookup

    I have tried a few different codes and still can't get the vlookup to work. The code is not all my own work, some was suggested by "Sixthsense" and it works.

    Please Login or Register  to view this content.
    However this always references cell F3 and I want it to reference F4 and F5 as each entry is made into the spreadsheet using the userform.

    I have also tried

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.
    I get either a #N/A or FALSE displayed.

    Any ideas?

    Regards

    Tig

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

  3. #3
    Registered User
    Join Date
    11-26-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Hi,

    Its a user form with an 'OK' button to transfer the data into the spreadsheet so therefore there would not be an opportunity to press CTRL+SHIFT+ENTER.

    What am I missing?

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    the syntax of second and third line shown is wrong.
    you cannot achieve multiple assignment in one line of code

    try writing in a cell
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    if A1<>A2 you will get TRUE as result

    excel first evaluates A1=A2 (gets false) and then evaluates false=false, which is true - and this is final result.

    so ... my vision ;-) of what you try to obtain in second line of your post is:

    Please Login or Register  to view this content.
    In simple words: first look for content of SapPartTextBox in Sheets2 column A, and copy the value from coresponding row in column B into textbox2 and also to current sheet in Cells(emptyRow, 7).
    Best Regards,

    Kaper

  5. #5
    Registered User
    Join Date
    11-26-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Hi Kaper,

    I see what you mean, but each time I put the code you suggest into my code it throws up an error.

    Regards

    Tig

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    1) what error? (number and description,
    2) where it occurs - press debyg and see yellow line
    3) what is in SapPartTextBox.Value
    and ... many others so probably best advice is:
    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Quote Originally Posted by Tig View Post
    Hi,

    Its a user form with an 'OK' button to transfer the data into the spreadsheet so therefore there would not be an opportunity to press CTRL+SHIFT+ENTER.

    What am I missing?
    Hmm... I was going to ask you to supply a sample workbook, not tell you about array formula.

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  9. #9
    Registered User
    Join Date
    11-26-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Hi Kapur,

    I have attached the workbook.

    I have desensitised the data.

    The error is Run-time error '9'
    Subscript out of range

    The line where the error occurs is the line

    Please Login or Register  to view this content.
    The data in the SapPartTextBox would be number between 1 and 14, this should use a vlookup to determine the colour in the 'TextBox2'.

    I have filled in the 1st 3 lines to give an idea of what the filled sheet would look like.

    Regards

    Tig
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    11-26-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Sorry,

    davesexcel, I put the wrong name at the top of the sheet.

    Please accept my apology for that.

    Regards

    Tig

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    =DEC2HEX(3563)
    has found the answer for ya
    Last edited by davesexcel; 01-03-2015 at 10:12 AM.

  12. #12
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    Try something like this..

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    as in a user form, each frame contain different group.. you need to call them using their name..
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  13. #13
    Registered User
    Join Date
    11-26-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: I have a userform and I want one of the text boxes to be populatated using vlookup

    To all the users who commented on this post and supplied answers, Thankyou. I am relatively new to Vba and so all your code has been a learning curve for me.

    Regards


    Tig

+ 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. Loop through userform text boxes
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2014, 10:41 AM
  2. [SOLVED] Clear all text boxes-combo boxes in a userform.
    By MariaPap in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-31-2014, 11:16 AM
  3. [SOLVED] Help with code for userform text boxes, combo boxes and excel
    By innerise in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-20-2014, 09:07 AM
  4. multiple text boxes on userform
    By stephen1000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-18-2009, 03:37 AM
  5. [SOLVED] Using userform, text boxes
    By Momo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2005, 12:06 PM

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