Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Clear entries on Combo box
I found code below while searching the net. It works, but how do you clear
the entry from the list when workbook is opened. For some reason, the cboMonth says "August" instead of blank? Private Sub Workbook_Open() With Sheet1.cboName .ListFillRange = "" .AddItem "John" .AddItem "Jay" .AddItem "Mark" .AddItem "Matt" .ListIndex = 0 End With End Sub Private Sub cboName_Change() For IndexNbr = cboMonth.ListCount - 1 To 0 Step -1 cboMonth.RemoveItem (IndexNbr) Next IndexNbr Select Case cboName.Value Case "John" cboMonth.AddItem "Jan" cboMonth.AddItem "February" cboMonth.AddItem "March" Case "Jay" cboMonth.AddItem "April" cboMonth.AddItem "May" cboMonth.AddItem "June" Case "Mark" cboMonth.AddItem "July" cboMonth.AddItem "August" cboMonth.AddItem "September" Case "Matt" cboMonth.AddItem "October" cboMonth.AddItem "November" cboMonth.AddItem "December" Case Else MsgBox cboName.Value & " Is Not Valid." End Select End Sub |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Clear entries on Combo box
If August is the value in that cboMonth box, then it's never being reset. It's
just the last value you had in that combobox when the workbook was saved. Try clearing the cboMonth in the workbook_open event: Option Explicit Private Sub Workbook_Open() Sheet1.cboMonth.Clear Sheet1.cboMonth.Value = "" With Sheet1.cboName .ListFillRange = "" .AddItem "John" .AddItem "Jay" .AddItem "Mark" .AddItem "Matt" .ListIndex = 0 End With End Sub casey wrote: I found code below while searching the net. It works, but how do you clear the entry from the list when workbook is opened. For some reason, the cboMonth says "August" instead of blank? Private Sub Workbook_Open() With Sheet1.cboName .ListFillRange = "" .AddItem "John" .AddItem "Jay" .AddItem "Mark" .AddItem "Matt" .ListIndex = 0 End With End Sub Private Sub cboName_Change() For IndexNbr = cboMonth.ListCount - 1 To 0 Step -1 cboMonth.RemoveItem (IndexNbr) Next IndexNbr Select Case cboName.Value Case "John" cboMonth.AddItem "Jan" cboMonth.AddItem "February" cboMonth.AddItem "March" Case "Jay" cboMonth.AddItem "April" cboMonth.AddItem "May" cboMonth.AddItem "June" Case "Mark" cboMonth.AddItem "July" cboMonth.AddItem "August" cboMonth.AddItem "September" Case "Matt" cboMonth.AddItem "October" cboMonth.AddItem "November" cboMonth.AddItem "December" Case Else MsgBox cboName.Value & " Is Not Valid." End Select End Sub -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Best way to populate worksheet from 2 combo boxes | Excel Worksheet Functions | |||
Macro that can run combo boxes | Excel Discussion (Misc queries) | |||
Using control to clear spreadsheet | Excel Discussion (Misc queries) | |||
dynamic combo boxes | Excel Worksheet Functions | |||
How do I autofill combo boxes with their destination cell? | Excel Worksheet Functions |