+ Reply to Thread
Results 1 to 14 of 14

Userform vlookup with the ability to save or select values

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Userform vlookup with the ability to save or select values

    Hi,

    I have very limited VBA skills and I have tried to get a vlookup working on a userform. I need data from a range selected in ComboBox1 to drop into Textbox1. I have tried but it doesn't work.

    I also need if possible a button that pushes the result of TextBox1 to a cell and another button that allows the user to edit the TextBox1 value in situ.

    I have attached a file with progress thus far!

    Thank you in advance.

    ** SOLVED THANK YOU **
    Attached Files Attached Files
    Last edited by jpruffle; 04-07-2009 at 04:14 AM.

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Userform vlookup with the ability to save or select values

    I've done a couple of things for you in the attached file. You didn't need to use VLookup. The combo box will value the Listindex attribute set to the one selected, so all you have to do be move column 2 of the combo to the list box. Also, I don't think you need to have a button to let the contents of list box be changed. If you just change it and then click "Copy to Sheet" the revised value will be copied.
    form_help.xls
    Let me know how you're doing.

  3. #3
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Userform vlookup with the ability to save or select values

    Thank you very much for the quick reply. That is almost exactly what I want but is it possible for the amended value in TextBox1 to be saved with a click of a button i.e. the cell value to be actually changed?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform vlookup with the ability to save or select values

    This code will load the combobox & when a selection is made enter the value in TextBox1
    Please Login or Register  to view this content.
    It's not clear what you want to change from the textbox. or where to copy it to
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform vlookup with the ability to save or select values

    You might be referring to the cell next to the listing, in which case
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Userform vlookup with the ability to save or select values

    Thanks that works exactly how I wanted it except that the Copy To Sheet button doesn't work.

    I basically need the user to be able to select an option from the drop down list, edit it if need be and either save it for later use or copy it to cell B16 for example.

    Also when I add several paragraphs in the drop down the text doesn't wrap is this possible?

    Again thank you in advance.

  7. #7
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Userform vlookup with the ability to save or select values

    Where do you want to save it for later use?

  8. #8
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Userform vlookup with the ability to save or select values

    Thanks for the reply.

    Basically I need to combine your code with RoyUK's.

    The value needs to go to cell B16 as an example if it is selected to be copied. Or amended in row I where it exists already.

    Does that make sense?

    Thanks

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform vlookup with the ability to save or select values

    The code that i posted amends the cell it picks the vlue from. Where do you want to save it to otherwise?

  10. #10
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Userform vlookup with the ability to save or select values

    In cell B16 please or anywhere as an example that I can use.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform vlookup with the ability to save or select values

    Is it always B16, i.e. do you want to overwrite previous values?
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Userform vlookup with the ability to save or select values

    That is exactly what I want.

    Sorry two more things if possible!

    Can it instead of replacing cell B16 copy down the page each time an entry is selected and copied. Ie fist one copied goes to B16 the next to B17 etc?

    Also, the contents of Textbox 1 will actually be sent using over code as the body of an email. However I cannot add returns on the text inside the box or do any formatting and the text doesn't wrap. Is there a better control to use rather than a Textbox?

    Thank you once again.

  13. #13
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Userform vlookup with the ability to save or select values

    Try this
    Please Login or Register  to view this content.
    You cannot format a TextBox. You can change it's MultiLine property to tue to allow the input to wrap

  14. #14
    Forum Contributor
    Join Date
    06-03-2008
    MS-Off Ver
    Excel 2007 (also have access to Excel 2000/2003)
    Posts
    368

    Re: Userform vlookup with the ability to save or select values

    Fantastic,

    One very final point. I have changed the multiline property to True. When I enter text and press return it takes me straight to the first button. Firstly can this be stopped so it simply creates a new paragraph and the user has to physically select the button?

    To get around it I have pressed Shift and Enter so I can create a new line within the textbox (to make it neater). When I do this and save it a square symbol appears instead of a simple blank return.

    Is there any way around either of these points?

    Thank you.

+ 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