Forever_EX
New Member
- Joined
- Mar 26, 2018
- Messages
- 22
I'm beginning to learn to code in Excel, and I have a question about grouping items.
I have about 100 different "types" of items that are separated into about 5 groups based on how I describe the item.
I created a user form that allows you to choose the item from a tiered drop down list and then loads a description of it into the cell.
So for example you choose "Cheese" (a food) and it returns "I love it!" You choose "Mice" (an animal) and it returns "Not so good!"
My question is, is there a way to group these seemingly unrelated items so that I don't have to type what to return for each individual item in my code?
Here is a sample of my code:
Thank you everybody
I have about 100 different "types" of items that are separated into about 5 groups based on how I describe the item.
I created a user form that allows you to choose the item from a tiered drop down list and then loads a description of it into the cell.
So for example you choose "Cheese" (a food) and it returns "I love it!" You choose "Mice" (an animal) and it returns "Not so good!"
My question is, is there a way to group these seemingly unrelated items so that I don't have to type what to return for each individual item in my code?
Here is a sample of my code:
Private Sub CommandButton1_Click()
Dim rng As Range
Set rng = Selection
'rng.Value = Second.Value
If Second.Value = "Cheese" Then rng.Value = "I love it!"
End Sub
Private Sub Main_Change()
Dim index As Integer
index = Main.ListIndex
Second.Clear
Select Case index
Case Is = 0
With Second
.AddItem "Dog"
.AddItem "Cat"
.AddItem "Mouse"
End With
Case Is = 1
With Second
.AddItem "Cheese"
.AddItem "Pickles"
.AddItem "Hot Dogs"
End With
End Select
End Sub
Private Sub UserForm_Initialize()
With Main
.AddItem "Animals"
.AddItem "Food"
End With
End Sub
Thank you everybody