ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
Evening,
Is there a different code when sorting letters that also contain numbers as opposed to just letters on there own ?
I ask becuase if i type in the correct TextBox the word HONDA i see the list sorts by customers name which is correct,so in my example ALEX 1, 2, 3, 4
But the issue i see if i type in the correct TextBox the word XL i see the list sorts in the column shown XL 700 1, 2, 3, 4 & the customers name is unsorted.
I assume if i type XL i expect to still see the customers name to be sorted NOT the XL part
Screen shots supplied to assist
Is there a different code when sorting letters that also contain numbers as opposed to just letters on there own ?
I ask becuase if i type in the correct TextBox the word HONDA i see the list sorts by customers name which is correct,so in my example ALEX 1, 2, 3, 4
But the issue i see if i type in the correct TextBox the word XL i see the list sorts in the column shown XL 700 1, 2, 3, 4 & the customers name is unsorted.
I assume if i type XL i expect to still see the customers name to be sorted NOT the XL part
Screen shots supplied to assist
Rich (BB code):
Private Sub TextBoxMODEL_Change()
TextBoxMODEL = UCase(TextBoxMODEL)
Dim r As Range, f As Range, cell As String, added As Boolean
Dim sh As Worksheet
Set sh = Sheets("DETAILS")
sh.Select
With ListBox1
.Clear
.ColumnCount = 7
.ColumnWidths = "0;180;150;150;100;80;60"
If TextBoxMODEL.Value = "" Then Exit Sub
Set r = Range("C2", Range("C" & Rows.Count).End(xlUp))
Set f = r.Find(TextBoxMODEL.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.Offset(, -2).Value
.List(i, 2) = f.Offset(, -1).Value
.List(i, 3) = f.Offset(, 0).Value
.List(i, 4) = f.Offset(, 1).Value
.List(i, 5) = f.Offset(, 4).Value
.List(i, 6) = f.Offset(, 5).Value
added = True
Exit For
End Select
Next
If added = False Then
.AddItem f.Value
.List(.ListCount - 1, 1) = f.Offset(, -2).Value
.List(.ListCount - 1, 2) = f.Offset(, -1).Value
.List(.ListCount - 1, 3) = f.Offset(, 0).Value
.List(.ListCount - 1, 4) = f.Offset(, 1).Value
.List(.ListCount - 1, 5) = f.Offset(, 4).Value
.List(.ListCount - 1, 6) = f.Offset(, 5).Value
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 MODEL WAS FOUND", vbCritical, "CLONING INFORMATION MESSAGE"
TextBoxMODEL.Value = ""
TextBoxMODEL.SetFocus
End If
End With
End Sub