+ Reply to Thread
Results 1 to 14 of 14

Vba vlookup & match value in combobox and textbox on a userform

  1. #1
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Vba vlookup & match value in combobox and textbox on a userform

    hi all,
    i'm attempting to run a vlookup and match search in a userform with the values from a text box and a combo box. using a formula works fine in the spreadsheet translating that however to vba not so easy.
    the formula is =VLOOKUP(R3,'Rate'!A2:AY157,MATCH(C7,'Rate'!B1:AY1)+1). R3 represents the TextBox ("TextBox1") and C7 represents the ComboBox("ComboBox1")

    here's what i have so far (im probably way off)

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Vba vlookup & match value in combobox and textbox on a userform

    Could you upload your workbook (without any sensitive data)?

  3. #3
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    here's a edited workbook (with sensitive data removed) forumlas and cells should still apply.
    i cant however show the userform too much sensitive data would have to be removed etc.
    thanks!
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Vba vlookup & match value in combobox and textbox on a userform

    Hi,

    I don't think you need to use both the index function and vlookup, as you can get the value column 4 within your lookup range through the index function.

    Try this (untested):

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Vba vlookup & match value in combobox and textbox on a userform

    We can refine it given the input in Sheet1 that I now see, but I hope that will be helpful and possibly in the right direction

  6. #6
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    whoops almost forgot to add i wanted the result to return to TextBox141(within the userform), any idea where it's returning now, i don't see it?

  7. #7
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    also i'm not sure why i put column 4 in there that was a mistake. i wanted to return the result (whichever column it may be in) depending on the number in combobox 1 which will be the name of the column its in.

  8. #8
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    bump, anyone?

  9. #9
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Vba vlookup & match value in combobox and textbox on a userform

    It's only a matter of putting the right variables into the code and then define the TextBox141 as myVal. Will the value of textbox1 be the date whereas combobox1 will be the column number?

    At the moment, the output (of the code I provided) is shown in the Immediate window (debug.print myVal), which can be displayed in Visual Basic by pressing CTRL+G.

  10. #10
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    yes (textbox1 is date, and combobox1 is the same as the column number in the first row) i've tired playing around with switching the textbox and combobox values towards the bottom but no dice also the debug is showing no result returned for any combination of alternatives for myVal including application.match(Me.TextBox1.Value,
    (same with combobox)

  11. #11
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    here's the workbook with a userform added.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Vba vlookup & match value in combobox and textbox on a userform

    Try this:

    Please Login or Register  to view this content.
    Last edited by berlan; 12-13-2013 at 03:17 PM.

  13. #13
    Registered User
    Join Date
    02-01-2011
    Location
    Philadelphia, Pennsylvania
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Vba vlookup & match value in combobox and textbox on a userform

    perfect! thanks a alot!

  14. #14
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Vba vlookup & match value in combobox and textbox on a userform

    You're welcome

+ 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. input the value of a Combobox and a textbox to a TEXTBOX directly from a userform
    By Gordonhk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2013, 03:25 PM
  2. [SOLVED] Excel Userform: Populate other controls (i.e. textbox & combobox) based on combobox select
    By MileHigh_PhD in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2013, 04:50 PM
  3. [SOLVED] Use combobox to fill textbox within userform
    By Orestees in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-26-2012, 03:39 PM
  4. Userform: Combobox value to WorkSheet Textbox
    By lankan12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2011, 01:56 AM
  5. Hide TextBox/ComboBox on UserForm
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2010, 02:47 PM

Tags for this Thread

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