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
Bookmarks