+ Reply to Thread
Results 1 to 2 of 2

textbox dependent on 2 combo boxes (user form) VBA

  1. #1
    Registered User
    Join Date
    03-20-2014
    Location
    NJ, USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Red face textbox dependent on 2 combo boxes (user form) VBA

    Hi Guys,
    I'm a newbie and was wondering if someone out there can shed some light on my dilemma with my code.

    I'm currently have creating a user form and I have a worksheet (master) that has 3 columns...col B:State, col C:Profession, col D:Salary

    On the excel side I have a code which works(perfectly) like this: =VLOOKUP(C40&"|"&C44,CHOOSE({1,2},master!B3:B12086&"|"&master!C3:C12086,master!D3:D12086),2,0)

    what it does is, that when a state is chosen from the pulldown and a profession is chosen from the profession pulldown, it refers back to my master worksheet range and
    returns the particular salary value, correlating to the particular state and profession into the cell.

    My questions is, how can I translate this formula to work in VBA coding for my user form to work the same as my excel.

    Any help or insight will be greatly appreciated.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: textbox dependent on 2 combo boxes (user form) VBA

    something like...
    Please Login or Register  to view this content.
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    03-20-2014
    Location
    NJ, USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: textbox dependent on 2 combo boxes (user form) VBA

    Thanks Tinbendr,

    I tried it but it didn't work. It has though given me a platform to begin from. One of the errors I got was {}, are not recognized apparently, in VBA coding.
    I did make a change too, where I failed to indicate that c40 is actually the combobox for State and c44 is actually the combobox for for Profession, to choose from.

    The following is the way I changed it in VBA.....

    Private Sub tbox1_Change()

    Me.comboState.Value=v1
    Me.comboProfession.Value=v2

    Me.tbox1=Application.WorksheetFunction.Vlookup(("v1") & ("v2"), CHOOSE ([1,2], Worksheets(master).Range("b3:b12086") & _
    Worksheets(master).Range("c3:c12086"), Worksheets(master).Range("d3:d12086")), 2,0)

    End Sub

+ 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. populating list boxes and combo boxes in a user form.
    By ahceinaej in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2014, 11:54 AM
  2. [SOLVED] Dependent drop down list in user form combo box vba
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-09-2014, 07:06 AM
  3. combo box user form code for two combo boxes
    By robert.begley1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-01-2012, 02:25 PM
  4. Excel Form - Dependent Combo Boxes Writing To A Cell
    By ll in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2006, 06:10 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