Ancient Wolf
Board Regular
- Joined
- Mar 17, 2009
- Messages
- 89
Asking for help again with Excel 2007
I am creating a spreadsheet that will use 5 combo boxes. Each selection in a combo box will affect the next one in line and change the available options. Using the coding below:
Private Sub ComboBox1_Change()
With ComboBox2
Select Case ComboBox1.Value
Case "Fruit"
.AddItem "apple"
.AddItem "orange"
Case "Vegetable"
.AddItem "brocoli"
End Select
End With
End Sub
I understand how to get the different combo boxes to change selections. However, I also need the items to be removed in case someone clicks the wrong choice and tries to go back to pick the correct one. I am currently trying to get the codes to remove the items added in by the .additem lines by using the .removeitem code or the .removeallitems code, but I keep running into errors. I can get one item to remove by doing it this way:
Case "Fruit"
.AddItem "apple"
.AddItem "orange"
Case "Vegetable"
.removeitem (1 / 2)
.AddItem "brocoli"
It will remove apple, but if I try to add a second remove line, or try to use the removeall, then I get a run error. Can anyone tell me what I am doing wrong?
I am creating a spreadsheet that will use 5 combo boxes. Each selection in a combo box will affect the next one in line and change the available options. Using the coding below:
Private Sub ComboBox1_Change()
With ComboBox2
Select Case ComboBox1.Value
Case "Fruit"
.AddItem "apple"
.AddItem "orange"
Case "Vegetable"
.AddItem "brocoli"
End Select
End With
End Sub
I understand how to get the different combo boxes to change selections. However, I also need the items to be removed in case someone clicks the wrong choice and tries to go back to pick the correct one. I am currently trying to get the codes to remove the items added in by the .additem lines by using the .removeitem code or the .removeallitems code, but I keep running into errors. I can get one item to remove by doing it this way:
Case "Fruit"
.AddItem "apple"
.AddItem "orange"
Case "Vegetable"
.removeitem (1 / 2)
.AddItem "brocoli"
It will remove apple, but if I try to add a second remove line, or try to use the removeall, then I get a run error. Can anyone tell me what I am doing wrong?