ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,726
- Office Version
- 2007
- Platform
- Windows
Morning.
The code below works but looking for an edit please.
I type AB02 in the search box & the listbox returns the results from column E
I wish to now type AB02 but in the listbox be able to see not only like before the results from column E BUT also column F,G,H
So it would look like this.
I type AB02 and the listbox would show example below
AB02
AAB02
AAAB02
But the new edit would return this,
AB02 BLUE 55 ABC123
AAB02 GREEN 88 DEF 456
AAAB02 RED 11 GHI 789
The code below works but looking for an edit please.
I type AB02 in the search box & the listbox returns the results from column E
I wish to now type AB02 but in the listbox be able to see not only like before the results from column E BUT also column F,G,H
So it would look like this.
I type AB02 and the listbox would show example below
AB02
AAB02
AAAB02
But the new edit would return this,
AB02 BLUE 55 ABC123
AAB02 GREEN 88 DEF 456
AAAB02 RED 11 GHI 789
Code:
Private Sub TextBox1_Change()
Dim r As Range, f As Range, Cell As String, added As Boolean
Dim sh As Worksheet
Set sh = Sheets("MC VIN")
sh.Select
With ListBox1
.Clear
.ColumnCount = 5
.ColumnWidths = "100;0"
If TextBox1.Value = "" Then Exit Sub
Set r = Range("E11", Range("E" & Rows.Count).End(xlUp))
Set f = r.Find(TextBox1.Value, LookIn:=xlValues, lookat:=xlPart)
If Not f Is Nothing Then
Cell = f.Address
Do
added = False
For i = 0 To .ListCount - 1
Select Case StrComp(.List(i), f.Value, vbTextCompare)
Case 0, 1
.AddItem f.Value, i
.List(i, 1) = f.Row
added = True
Exit For
End Select
Next
If added = False Then
.AddItem f.Value
.List(.ListCount - 1, 1) = f.Row
End If
Set f = r.FindNext(f)
Loop While Not f Is Nothing And f.Address <> Cell
TextBox1 = UCase(TextBox1)
Else
MsgBox "NO VIN MODEL WAS FOUND USING THAT INFORMATION", vbCritical, "VIN MODEL SEARCH MESSAGE"
TextBox1.Value = ""
TextBox1.SetFocus
End If
End With
End Sub