![]() |
|
|
|
#1
|
||||
|
||||
|
Those constants are all defined in Excel. In Excel these resolve as
xlBeginsWith = 2 xlContains = 0 xlDoesNotContain = 1 xlEndsWith = 3 xlNoFilter = "" The ComboBox in a VBA userform is essentially the same but when interacting with the application may cause you to use different methods to achieve the same thing. For instance a Range in Excel can be used to populate the .List property of a combobox. Word requires you to convert a Range into an array before you can populate the .List property.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#2
|
|||
|
|||
|
In order to avoid confussion. i Ve changed as per Word Requirements only the SELECT CASE part
Code:
Private Sub ComboBox1_Change()
Dim oneItem As Variant
Dim FilteredItems() As String
Dim NotFlag As Boolean
Dim Pointer As Long, i As Long
If DisableMyEvents Then Exit Sub
If AbortOne Then AbortOne = False: Exit Sub
If TypeName(FullList) Like "*()" Then
ReDim FilteredItems(1 To UBound(FullList))
DisableMyEvents = True
Pointer = 0
With Me.ComboBox1
Select Case FilterStyle
Case 2: .Tag = LCase(.Text) & "*"
Case 0: .Tag = "*" & LCase(.Text) & "*"
Case 1: .Tag = "*" & LCase(.Text) & "*": NotFlag = True
Case 3: .Tag = "*" & LCase(.Text)
Case "": .Tag = "*"
End Select
For Each oneItem In FullList
If (LCase(oneItem) Like .Tag) Xor NotFlag Then
Pointer = Pointer + 1
FilteredItems(Pointer) = oneItem
End If
Next oneItem
.List = FilteredItems
.DropDown
DisableMyEvents = False
If Pointer = 1 Then .ListIndex = 0
End With
End If
End Sub
Code:
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) IsArrow = KeyCode = vbKeyUp Or KeyCode = vbKeyDown If KeyCode = vbKeyReturn Then ComboBox1.List = FullList End Sub SMehta Thread 3: No: 46521 : Post No12 : TM 25 |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trying to get number of para in Combobox | SMehta | Word VBA | 2 | 02-20-2021 07:15 AM |
| How to autofilter by exact date? | LearnerExcel | Excel | 5 | 06-19-2018 03:30 PM |
| Autofilter on two Date Columns | OTPM | Excel Programming | 3 | 04-29-2014 12:56 AM |
Sum on AutoFilter
|
Grasshopper | Excel | 3 | 02-14-2013 01:41 AM |
AutoFilter Criteria3
|
coxjamd | Excel Programming | 2 | 01-17-2013 02:24 PM |