View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
AMDRIT AMDRIT is offline
external usenet poster
 
Posts: 31
Default 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?