Hello
I was trying to implement to search Para No(s). like Autofilter Combobox
via
Auto Filtering ComboBox - TIP, TRICKS & CODE - OzGrid Free Excel/VBA Help Forum
But somehow it is not Smooth operating. I dont know why
Because when i type the Para No as 1 inthe Combobox Change Event
then the dropdown should show list of
1, 10,11, 12,13,14,......21,31 etc
if i type 2 then result
2, 12, 22,32.....etc
The above results not happening. Dont know why
Code:
Option Explicit
Public myArrayParaList As Variant
Public IsArrow As Boolean
Public Sub GetParaList()
Dim sList As String, i As Long, sText As String, myArrayParaList As Variant
For i = 1 To ActiveDocument.Paragraphs.Count
sText = Trim(Trim(ActiveDocument.Paragraphs(i).Range.Text))
If Split(sText, vbCr)(0) <> "" Then
sList = sList & i & ","
myArrayParaList = Split(sList, ",")
End If
Next i
cmbParaNos.List = myArrayParaList
End Sub
Private Sub cmbParaNos_Change()
Dim i As Long
Dim oBkMrk As Bookmark
Dim wdActDoc As Document
Set wdActDoc = ActiveDocument
With cmbParaNos
If Not IsArrow Then .List = myArrayParaList
If .ListIndex = -1 And Val(Len(.Text)) Then
For i = .ListCount - 1 To 0 Step -1
'If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
If InStr(1, .List(i), Val(.Text), 1) = 0 Then .RemoveItem i
Next i
.DropDown
End If
End With
End Sub
Private Sub cmbParaNos_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
IsArrow = KeyCode = vbKeyUp Or KeyCode = vbKeyDown
If KeyCode = vbKeyReturn Then cmbParaNos.List = myArrayParaList
End Sub
Your guidance shall be appreciated.
SMehta
Thread 3: No: 46521 : Post No1 : TM 19