+ Reply to Thread
Results 1 to 34 of 34

How to write vlookup Formula w/in a Userform Textbox & show user form on start up of doc.

  1. #1
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    How to write vlookup Formula w/in a Userform Textbox & show user form on start up of doc.

    Greetings again all-two part question here,

    I have a user form I'm creating, see attached image, and I would like to populate a result in the other three text boxes when the "Property Case" field has been entered. Also, what code is needed to automatically show the form on startup of the document? I have it fine for floating, but can't quite get it to show on startup.

    Thank you everyone!
    Kondukt

    User Form.PNG

  2. #2
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    UPDATE: I've been continuing to Google the crap outta this and found how to make it open on start up and to add formulas to text boxes but I'm running into a wall.

    Please Login or Register  to view this content.
    The above is what I'm using; however, it seems to error out with a "disambiguous" notice after I enter in the second code for the buttons. If I have it in there for one text box then it works just fine. As soon as I add the code for the second check box it doesn't work anymore. I've tried switching the "userform" to the form name "frmFloatingWindow" to no avail.

    I'm not understanding why it's bouncing back.

  3. #3
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Edit: Or had edited the previous post and the forum decided to make a new post.

    I got this to work by putting all the textbox# lines under one PrivateSub.

    How do I code the attached form, using the "Property Case" field, to type in a value thus returning the vlookup extractions in the other cells/textboxes? As you can see I've tied the texboxes to a cell on the worksheet, but how do code the cell to reference the texbox?

    I want to type in a value in the property case field and have it return the vlookup answers for the other text boxes.

    Or, how can I do this effectively?

  4. #4
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Friendly bump that's still needing to be resolved.

  5. #5
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Bumpity bump. Didn't think this was going to be that difficult of a request.

    Anyone home?

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Where have you tied the textboxes to cells?

    This code will only put intial values in the textboxes.
    Please Login or Register  to view this content.
    You mention doing a VLookup but give no details about your data and how it's structured.

    Could you attach a sample workbook?
    If posting code please use code tags, see here.

  7. #7
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    I don't really know how best to structure what I'm trying to do, hence why I am posting. The textboxes can be tied to cells as coded above, our simply entering in the sheet and cell (IOC!D25) under the "control source" via the textbox's properties.

    What I am trying to do is with the attached image (See OP) of my control form I want to enter in a value under "Property Case" and once that has been entered, values from the database are then returned in the other three boxes via a formula-vlookup. How is this done?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    It's hard to tell how it's done without knowing anything at all about your data.

    Where is it located?

    Which column should be looked in for property case?

    Which column(s) have the values that should be returned to the textboxes?

  9. #9
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Darn, I was kind of hoping there was a code/method that one could point me to for myself to learn/determine.

    However, for the sake of my sanity I've attached the document.

    The vlookup codes for the text boxes are-for transparency-as follows:

    1.) VA Bid: =VLOOKUP(B25,DB!G2:W5000,4,"false")
    2.) %: =VLOOKUP(B25,DB!G2:W5000,5,"false")
    3.) Bid Date: =VLOOKUP(B25,DB!G2:W5000,6,"false")

    These are all located on the IOC sheet, first tab of this workbook. The vlookups are searching through the database tab. I would attach the document, but adding the userform seems to have set the file size too large to upload.

    The text boxes are static via a userform that is constantly displayed.

    I am not sure how best to formulate/format/code/?? this to work most efficiently.

    nublet here.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Sorry, but I'm a little confused.

    Do you want to lookup the value in the texbox or the value in B25?

  11. #11
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    In the user form I provided an image of, in the text box labeled "Property Case" I want to be able to type in a value and once that is entered I would like the remaining three text boxes to return a value as determined by the vlookup formulas I posted.

    My Google searches told me to use a cell to link the textbox to in order to return a formulated value. I dont know of any other way to add a formula into a textbox.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    You don't need to use a cell link, the formulas could be done in the code.

    Please Login or Register  to view this content.
    Also, there's different methods that can be used for this sort of thing.

    For example, you could use Find to find the row the property case is on.

    Or Match.

  13. #13
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Ok, I figured there had to be a way.

    Then I would write it as

    Please Login or Register  to view this content.
    And so on per text box? Safe to presume "txtProperyCase" is telling where to look for the query when returning the value?

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    When exactly do you want this to happen?

    That code seems to indicate it's when the form opens, but when the form opens the property case textbox will be empty.

    PS txtPropertyCase is supposed to refer to the textbox where the user will enter the property case.

  15. #15
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Ah, see. nublet here.

    I only want the response to return a value when the textbox has a value entered in. So, it's simply a "private sub" type of event?

    I really need to get my **** into a vba course.

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    A textbox has quite a few events, I think I'd pick Exit.

    An easy way to access the events of a control is to open the userform module, select the control from the left dropdown and the event dropdown.

    This should generate the proper code stub for the event.

    PS In the previous code it should be UserForm_Initialize not <TheNameOfTheForm>_Initialize.

  17. #17
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    I entered in one to test and the code part of it in red was showing up red on the module too. It snaps to the "G2:5000" part.

    I selected "Textbox3" in the module's left drop down and chose "exit" on the right drop down.

    Please Login or Register  to view this content.

  18. #18
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    You seem to have lost the quotes around G2:W5000.

  19. #19
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Indeed I did; however, it is still not pulling the data.

    Attached is a screen shot of my monitors showing on one the DB screen with just the cells needed filled out to test this little sucker and on the other is the VBA screen with the code as is.

    Unfortunately it is not pulling the data into the text boxes. Text box three is the "Bidded On" box that we've started a test code on. There was no returned value.

    And i also just realized it should be six and not four in the code for which column to pull.

    By the way, thank you for the help as we work toward the goal.

  20. #20
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    There's not attachment.

    If you are going to attach anything a workbook would be best.

    You said it was too large, but you don't need to attach the actuall workbook. A cutdown version should do.

  21. #21
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Good Morning again! Aaaaand back at it. This little bugger is my last hitch on my sheet and gah wish I could go Office Space on it.

    Alright, so I would love to attach the document but after I created the userform the file went to 2.5mb. I've stripped the doc of any other unncessary modules but it's still sitting at 2.25mbs.

    Suggestions?

    TxtBox3.jpg

    This image is the one I intended to attach before I had to take off yesterday.

  22. #22
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Soooo. I really want to close this sucker out.

    I've provided several images of the user form, and the vlookups I'm wanting to create in the textboxes referencing the "txtPropertycase" text box.

    Helpful people are unable to provide the code for this?

    Again, I can't shrink the document anymore than it already is.

    What other information might I be able to specifically provide to get some generous folks to ignore my previous "wanting to learn" comment and just code it for meh?



    Thanks dudes.

  23. #23
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    I posted code that should work.

    Have you checked the code is being triggered?

    You can do that by setting a breakpoint (F9) on the first line of the code, opening the userform, entering something in the property case textbox and tabbing out.

    If the code is being triggered you should be transferred to the line of code where you set the breakpoint.

    If that doesn't happen then the code isn't being triggered for some reason

    Why is hard to tell why without an an example workbook - could be as simple as an incorrect name in the code.

    Actually, which textbox have you added the code for?

    It should be added for the property case textbox, not one of the textboxes, bidded on?, you want to fill with data based on what's been entered in the property case textbox.


    PS What exactly have you tried to create a cutdown version of your workbook?

    Have you tried removing formatting?

    Did you try copying just relevant data and the relevant userform to a blank workbook?

  24. #24
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Yes, I've added that exact code to the Property Case text box code and when tabbing it errors out asking to debug/end.

    Please Login or Register  to view this content.
    I've stripped this down to only two sheets, the main and the db..that data is only 73 rows...IT IS the userform spiking its size. I can't remove the user form because that's what we're trying to code. Can you pm me your email and I'll shoot it over to ya that way?

    Have cleared ALL the formatting and all the coding say for the one in question, it is NOT dropping below 1.83 mb.
    Last edited by Miskondukt; 02-14-2013 at 12:04 AM.

  25. #25
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Something strange is going on, a userform can't take up that much room.

    Anyway, what's the error message?

  26. #26
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    txterror.PNG

    That little bugger.

    Agreed, something strange and I kid you not the sheet I've stripped is STRIPPED! I don't get it. Hell, I even removed most of the buttons on the user form too. Will keep trying to find where this memory is at on it.

  27. #27
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Finally got it under!

    Further down rows were still formatted.
    Attached Files Attached Files

  28. #28
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    The error is caused by the VLookup failing.

    It's easy to deal with the error, harder to find out why it happened.

    Perhaps you should upload a sample file without a form.


    PS You could try exporting the form (File>Export File...) and then importing (File>Import File...) it to a blank worksheet.

  29. #29
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    I did get it to post. the stripped down one.

  30. #30
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    In the code I posted way back I used txtPropertyCase in the VLookup for the name of the property case textbox.

    On your form the property case textbox is called TextBox1.

    So you need to change the lookup to reflect that.

  31. #31
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    That did it and I could have sworn I tried that variation too!

    Awh man, ty for working this through to conclusion! jiminy christmas batman!

    Now, am I able to assign formatting for date, currency and %s in the textboxes?

  32. #32
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    Yes, you can use VBA's Format function.
    Please Login or Register  to view this content.
    By the way, I notice that most of the properties have 2 entries.

    VLookup will only pick up the first one.

    For example for '201-317157' the lookup would return 21580 for VA BId from row 9, but in same column in the row below is 20750.

    Is that going to be a problem?

  33. #33
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    No, it won't be a problem. That tab will be sorted to list most recent-which is what we're wanting to pull.

  34. #34
    Forum Contributor
    Join Date
    01-19-2013
    Location
    Las Vegas, NV
    MS-Off Ver
    Office 365 2016
    Posts
    214

    Re: How to write vlookup Formula w/in a Userform Textbox & show user form on start up of d

    http://i.imgur.com/Ft3NPFX.png


    Thank you so very much.

    This can be marked closed/solved.

+ 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