littleguy1810
New Member
- Joined
- Aug 21, 2014
- Messages
- 40
Hi All,
I have this code running in a user form, I would like to be able to let the user select a category then, the PartIDList will choose from a list of items within that category only. you see the PartIDList list is hundreds long I want to shorten this to help the user. I can split the list into 5 columns easily and name the range, just need help with the code
The items fall into 5 categories,
1 - Flavour
2 - Oil
3 - Pellet
4 - Film
5 - Cases
Any suggestions?
Thanks
Mark
I have this code running in a user form, I would like to be able to let the user select a category then, the PartIDList will choose from a list of items within that category only. you see the PartIDList list is hundreds long I want to shorten this to help the user. I can split the list into 5 columns easily and name the range, just need help with the code
The items fall into 5 categories,
1 - Flavour
2 - Oil
3 - Pellet
4 - Film
5 - Cases
Any suggestions?
Thanks
Mark
Code:
Private Sub UserForm_Initialize()
Dim cPart As Range
Dim cLoc As Range
Dim cEmp As Range
Dim cCat As Range
Dim ws As Worksheet
Set ws = Worksheets("LookupLists")
For Each cEmp In ws.Range("Employee")
With Me.cboEmployee
.AddItem cEmp.Value
End With
Next cEmp
For Each cCat In ws.Range("Category")
With Me.cboCategory
.AddItem cCat.Value
End With
Next cCat
For Each cPart In ws.Range("PartIDList")
With Me.cboPart
.AddItem cPart.Value
.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
End With
Next cPart
For Each cLoc In ws.Range("LocationList")
With Me.cboLocation
.AddItem cLoc.Value
End With
Next cLoc
Me.txtDate.Value = Format(Date, "Medium Date")
Me.txtQty.Value = ""
Me.cboPart.SetFocus
End Sub