Results 1 to 6 of 6

Dependent Combobox in Excel Userform

Threaded View

  1. #1
    Registered User
    Join Date
    12-06-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    8

    Dependent Combobox in Excel Userform

    Hi,
    I am very new to excel VBA programming, and I am trying to create userform with Comboboxes.
    Here is what I have so far,

    userform named (EXPENSE)
    Combobox1 (CboECategory)
    Combobox2 (CBoESubCategory)
    Commandbutton 1 (CmdSave)
    Commandbutton 2 (CmdClose)

    I also have Named Lists for "Exp_Category_List" and "Exp_Subcategory_List" in Sheet named LookupLists

    Below is the code to populate the comboboxes:

    Private Sub UserForm_Initialize()
    
        Dim cCategory As Range
        Dim cSubCategory As Range
        Dim ws As Worksheet
        Set ws = Worksheets("LookupLists")
    
        For Each cCategory In ws.Range("EXP_CATEGORY_List")
            With Me.CboECategory
            .AddItem cCategory.Value
            .List(.ListCount - 1, 1) = cCategory.Offset(0, 1).Value
            End With
        Next cCategory
        
    '          '  If CboECategory.Value = "CASH/CREDIT ACCOUNT" Then
    '                For Each cSubCategory In ws.Range("EXP_CC_List")
    '                    With Me.CboESubCategory
    '                    .AddItem cSubCategory.Value
    '                    .List(.ListCount - 1, 1) = cSubCategory.Offset(0, 1).Value
    '                    End With
    '                Next cSubCategory
    '           ' End If
        
    End Sub
    I can get the "CboECategory" combobox to populate with the given list. But I cannot get the "CboESubcategory" combobox to populate depending upon the value in first combobox. As seen above, the commented code I used doesn't list the required values.
    Any help would be greatly appreciated.

    Thanks
    2Deep
    Last edited by 2Deep; 12-07-2010 at 07:08 PM. Reason: code tags required please read the forum rules

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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