ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Hi,
I currently use the code shown below.
It does what i require fine but now i also wish to get in ListBox the info from column E
Currently in the listbox i see say Tom Jones but it should now show say Tom Jones Music Singer etc etc
Please advise what i need to add & also where to put it etc.
I can then follow this advice for my other codes
Thanks
I currently use the code shown below.
It does what i require fine but now i also wish to get in ListBox the info from column E
Currently in the listbox i see say Tom Jones but it should now show say Tom Jones Music Singer etc etc
Please advise what i need to add & also where to put it etc.
I can then follow this advice for my other codes
Thanks
VBA Code:
Private Sub TextBoxVehicle_Change()
Dim r As Range, f As Range, cell As String, added As Boolean
Dim sh As Worksheet
Set sh = Sheets("DATABASE")
sh.Select
With ListBoxSearch
.Clear
.ColumnCount = 2
.ColumnWidths = "100;0"
If TextBoxVehicle.Value = "" Then Exit Sub
Set r = Range("D6", Range("D" & Rows.Count).End(xlUp))
Set f = r.Find(TextBoxVehicle.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
TextBoxSearch = UCase(TextBoxSearch)
.TopIndex = 0
Else
MsgBox "NO ITEM WAS FOUND USING THAT INFORMATION", vbCritical, "DATABASE SHEET ITEM SEARCH"
TextBoxVehicle.Value = ""
TextBoxVehicle.SetFocus
End If
End With
End Sub
End Sub