+ Reply to Thread
Results 1 to 4 of 4

VBA Cascading dropdown for user form

Hybrid View

dbarcl10 VBA Cascading dropdown for... 05-15-2017, 05:52 AM
Sadath31 Re: VBA Cascading dropdown... 05-15-2017, 06:10 AM
dbarcl10 Re: VBA Cascading dropdown... 05-15-2017, 06:35 AM
Sadath31 Re: VBA Cascading dropdown... 05-15-2017, 07:27 AM
  1. #1
    Registered User
    Join Date
    09-10-2014
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    6

    Thumbs up VBA Cascading dropdown for user form

    Hi All, VBA newbie here.

    I am trying to create a code for a userform where the options for combobox2 will be dependent on the option chosen in combobox1, and the options in combobox3 will depend on the chosen option on combobox2. I think this should be possible, but can't find any code anywhere that helps.

    Combobox1 = Transaction Type, i.e. income, expenditure, transfer
    Combobox2 = if combobox1 = expenditure, direct debit, standing order or card payment
    Combobox3 = if combobox2 = direct debit, mortgage, car, etc.
    if combobox1 = income, salary, interest, etc.

    Thanks in advance for any help!

  2. #2
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: VBA Cascading dropdown for user form

    assume sheet1 , range a2 to down have your combobox1 data then

    Private Sub UserForm_Initialize()
    ComboBox1.RowSource = Sheets("sheet1").Range("a2", Range("A2").End(xlDown)).Address
    End Sub
    combobox2 will populate based on combobox1.value

    Private Sub ComboBox1_Change()
    Select Case ComboBox1.Value
        Case Is = "Income": ComboBox2.RowSource = Sheets("sheet1").Range("b2", Range("b2").End(xlDown)).Address
        Case Is = "Expenditure": ComboBox2.RowSource = Sheets("sheet1").Range("c2", Range("c2").End(xlDown)).Address
        Case Is = "Transfer": ComboBox2.RowSource = Sheets("sheet1").Range("d2", Range("d2").End(xlDown)).Address
    End Select
    End Sub

  3. #3
    Registered User
    Join Date
    09-10-2014
    Location
    Scotland
    MS-Off Ver
    2007
    Posts
    6

    Re: VBA Cascading dropdown for user form

    Great, thanks for the speedy reply!

    I've added the code that you've suggested, and pleased to say that it works exactly as I had hoped! Only one query though - is it possible to change the "expenditure", "income" and "transfer" in combobox2 to cell references in case I ever change the text in future?

  4. #4
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: VBA Cascading dropdown for user form

    Hi

    change the code (comboxbox1_Change) to below


    Private Sub ComboBox1_Change()
        ComboBox2.RowSource = Sheets("sheet1").Range(Range("b2").Offset(0, ComboBox1.ListIndex), _
        Range("b2").Offset(0, ComboBox1.ListIndex).End(xlDown)).Address
    End Sub
    now you can have whatever values of combobox1 in cells A2 down
    and comboxbox2 values B2 to down, C2 to down ...... so on....

+ 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. [SOLVED] User form dropdown box with addresses
    By TRD_Purchasing in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2016, 11:47 AM
  2. User Form Dependent Dropdown (ComboBox)
    By tmleynek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2015, 04:45 PM
  3. Cascading Dropdown for A Calendar
    By pspunlimited in forum Excel General
    Replies: 17
    Last Post: 02-05-2015, 03:44 AM
  4. [SOLVED] Cascading user form combo boxes?
    By ciapul12 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2014, 03:20 PM
  5. Dropdown box on user form to select macros
    By FISMitch in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-29-2013, 09:30 AM
  6. [SOLVED] Cascading dropdown lists all tied to first dropdown
    By ruthl in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-18-2012, 08:03 PM
  7. Cascading Combo Boxes in User Form
    By CRIMEDOG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2009, 10:44 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