hi
Pls sorry for the long post... but i really in need of a solution. so pls be patient with me
I have 2 dependent comboboxes. second one populates based on selection of first combobox.
My problem is.. I select the first combobox value. This results in population of second one.
when i type a value in the second combobox which is not present in the listed values i.e., any random text or garbage value, and then go back to first combobox, change the selection... This is not emptying the random text/garbage value i have typed in the second combobox.
Is there any way to insert some code to do this???
Below is my code:
populating values in First combobox:
Private Sub UserForm_Initialize()
With drpSearchBy
.AddItem "Emp ID"
.AddItem "Name"
.AddItem "Department"
End With
End Sub
populating values in second combobox: (i have used a sub createListByRef() to pull values from a sheet to populate)
Private Sub drpSearchBy_DropButt*******()
Dim rowCnt, index As Integer
Dim sh As Worksheet
Dim strRange As String
index = drpSearchBy.ListIndex
Set sh = Sheets("Forecast")
rowCnt = sh.UsedRange.Rows.count
drpSearchText.Clear
Select Case index
Case Is = 0
strRange = "B2:" + "B" & rowCnt
Call createListByRef(strRange)
Case Is = 1
strRange = "C2:" + "C" & rowCnt
Call createListByRef(strRange)
Case Is = 2
strRange = "D2:" + "D" & rowCnt
Call createListByRef(strRange)
End Select
End Sub
Pls sorry for the long post... but i really in need of a solution. so pls be patient with me
I have 2 dependent comboboxes. second one populates based on selection of first combobox.
My problem is.. I select the first combobox value. This results in population of second one.
when i type a value in the second combobox which is not present in the listed values i.e., any random text or garbage value, and then go back to first combobox, change the selection... This is not emptying the random text/garbage value i have typed in the second combobox.
Is there any way to insert some code to do this???
Below is my code:
populating values in First combobox:
Private Sub UserForm_Initialize()
With drpSearchBy
.AddItem "Emp ID"
.AddItem "Name"
.AddItem "Department"
End With
End Sub
populating values in second combobox: (i have used a sub createListByRef() to pull values from a sheet to populate)
Private Sub drpSearchBy_DropButt*******()
Dim rowCnt, index As Integer
Dim sh As Worksheet
Dim strRange As String
index = drpSearchBy.ListIndex
Set sh = Sheets("Forecast")
rowCnt = sh.UsedRange.Rows.count
drpSearchText.Clear
Select Case index
Case Is = 0
strRange = "B2:" + "B" & rowCnt
Call createListByRef(strRange)
Case Is = 1
strRange = "C2:" + "C" & rowCnt
Call createListByRef(strRange)
Case Is = 2
strRange = "D2:" + "D" & rowCnt
Call createListByRef(strRange)
End Select
End Sub