![]() |
combobox problem
I have a userform for entry that has a combobox. Nothing appears in the drop
down list. I would like the combobox to add items enterd into as text in the drop down menu if they are not already there. Is there a way to do this? |
combobox problem
try this: combobox name is cboTest Private Sub cboTest_AfterUpdate() Dim sTemp As String Dim sList As Variant Dim iLoop As Integer Dim bFound As Boolean sTemp = cboTest.Text If Len(Trim(sTemp)) 0 Then If cboTest.ListCount = 0 Then ReDim sList(0) sList(0) = sTemp cboTest.List = sList Exit Sub End If 'Replace with copymem api 'copy just the first dimension ReDim sList(cboTest.ListCount) For iLoop = 0 To cboTest.ListCount - 1 sList(iLoop) = cboTest.List(iLoop) Next 'iLoop 'End replace with copymem api For iLoop = 0 To cboTest.ListCount - 1 If StrComp(sTemp, sList(iLoop), vbTextCompare) = 0 Then bFound = True End If Next 'iLoop If Not bFound And cboTest.ListCount 0 Then ReDim Preserve sList(cboTest.ListCount) sList(cboTest.ListCount) = sTemp End If cboTest.Clear cboTest.List = sList End If End Sub "Rbp9ad" wrote in message ... I have a userform for entry that has a combobox. Nothing appears in the drop down list. I would like the combobox to add items enterd into as text in the drop down menu if they are not already there. Is there a way to do this? |
combobox problem
Alternatively you can simply use: If not bFound then cboTest.Additem sTemp in place of If Not bFound And cboTest.ListCount 0 Then ReDim Preserve sList(cboTest.ListCount) sList(cboTest.ListCount) = sTemp End If cboTest.Clear cboTest.List = sList "AMDRIT" wrote in message ... try this: combobox name is cboTest Private Sub cboTest_AfterUpdate() Dim sTemp As String Dim sList As Variant Dim iLoop As Integer Dim bFound As Boolean sTemp = cboTest.Text If Len(Trim(sTemp)) 0 Then If cboTest.ListCount = 0 Then ReDim sList(0) sList(0) = sTemp cboTest.List = sList Exit Sub End If 'Replace with copymem api 'copy just the first dimension ReDim sList(cboTest.ListCount) For iLoop = 0 To cboTest.ListCount - 1 sList(iLoop) = cboTest.List(iLoop) Next 'iLoop 'End replace with copymem api For iLoop = 0 To cboTest.ListCount - 1 If StrComp(sTemp, sList(iLoop), vbTextCompare) = 0 Then bFound = True End If Next 'iLoop If Not bFound And cboTest.ListCount 0 Then ReDim Preserve sList(cboTest.ListCount) sList(cboTest.ListCount) = sTemp End If cboTest.Clear cboTest.List = sList End If End Sub "Rbp9ad" wrote in message ... I have a userform for entry that has a combobox. Nothing appears in the drop down list. I would like the combobox to add items enterd into as text in the drop down menu if they are not already there. Is there a way to do this? |
All times are GMT +1. The time now is 03:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com