One the best approch for this requirement is to add one textbox as search bar which provides the same result you reuired.
Here we need to focus on three things. I'm cosidering that your combobox is in the userform1
and your students data list is in the sheet1.
Now,
There are two events you need configure to perform this task.
1. UserForm_Initialize
2. TextBox1_Change
and the one sub procedure which will populate the result based on the keyword in the textbox
3. Populate_Combobox
Now
Coding for the 1 & 2 is the same
Private Sub TextBox1_Change()
Populate_Combobox
End Sub
Private Sub UserForm_Initialize()
Populate_Combobox
End Sub
Now let's see the code for the Sub Procedure
Private Sub Populate_Combobox()
Dim I As Long
I = 2
Dim LenofStr As Long
LenofStr = 0
With UserForm1
.ComboBox1.Clear
If .TextBox1.Value = vbNullString Then
Do Until Sheet1.Cells(I, 1).Value = Empty
.ComboBox1.AddItem Sheet1.Cells(I, 1).Value
I = I + 1
Loop
Else
LenofStr = VBA.Len(.TextBox1.Value)
Do Until Sheet1.Cells(I, 1).Value = Empty
If VBA.Left(VBA.UCase(Sheet1.Cells(I, 1).Value), LenofStr) = VBA.UCase(.TextBox1.Value) Then
.ComboBox1.AddItem Sheet1.Cells(I, 1).Value
End If
I = I + 1
Loop
End If
End With
End Sub
I have also attached images with this post
Subscribe to:
Post Comments (Atom)
IsValidPasswordString Function
'Following function will verify if the password string contains following characters or not? Rem : List of Characters Group - ASCII Rem ...
-
Here is the complete VBA code to import XML Data into the Excel Workbook in a completely dynamic approach. Look at the following video. ...
-
Show and Hide Columns one by one by Spin button up to mentioned columns limits. this is going to be the best small tool for excel users. ...
-
When we talk about Developing Apps on Excel VBA, we have two straight options for designing the user interface of the app. 1. Worksheet base...
No comments:
Post a Comment