Consulting

Results 1 to 7 of 7

Thread: VBA- Inex Matchdex Match?

  1. #1

    VBA- Inex Matchdex Match?

    Hi guys, (apologies for the title.. not sure what happened there.. was ok until I clicked save)

    I have a table of data which is three columns wide and hundreds and hundreds of rows in length.

    What I need is a user form that if I type a Number in say Textbox1..

    It finds that number in column A then returns Column B in textbox2 and Column C in Textbox 3.

    How do I code this in VBA?

  2. #2

  3. #3
    Thanks SNB but doesn't really help much. All the columns are in excel. The userform will open blank.. a user will type in a number (which is what the search criteria will be). then click the button. Its on this click I need the VBA to fire using textbox 1 as search criteria..

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Hmmmm... seems to me that you might need something to be called (other code) on completion of the textbox entry.

    Maybe...
    Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        If KeyCode = vbKeyReturn Then
            CommandButton1_Click
        End If
    End Sub
    Then you use a Vlookup formula to find the text entry within the table of data.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Expert mperrah's Avatar
    Joined
    Mar 2005
    Posts
    744
    Location
    vbax53854.xlsm
    Sorry late in the game, but here is a userform and sheet solution.
    I used a search button to change label captions based on selection from the list. (have the search item selected when you click search)
    The userform loads all three columns but hides the last 2, then updates the captions when you click search.

    On the sheet I used a data validation list and index/match to find the other 2 column values.

    hope this helps

    -mark

  6. #6
    Thanks Mark, that actually does a wonderful job. Least I know it can do what I want it to do. Ill have a play with the list bit as I think the user wants to be able to type his own search value, but that's easily done.

  7. #7
    VBAX Expert mperrah's Avatar
    Joined
    Mar 2005
    Posts
    744
    Location
    vbax53854_v2.xlsm
    Here you go.
    This adds a command button to load the form.
    The close button code is added.
    I hid the listbox that loads the sheet values
    and added a text box to let the user type their own number,
    then the search button starts a looks for a match of the input and the hidden listbox values first column.
    then displays the matches adjacent columns as requested.

    Hope this helps
    - I also removed the drop down from the sheet so it works the same way as the new form...

    -mark

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •