ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,199
- Office Version
- 2007
- Platform
- Windows
Evening,
I am using the working supplied code.
The ListBox is populated from information on my worksheet.
On my worksheet the date in column G is shown like 17/02/2020 but what i see in the ListBox is 2/17/2020
Please advise how i alter it so the ListBox matches the format of the worksheet.
I am using the working supplied code.
The ListBox is populated from information on my worksheet.
On my worksheet the date in column G is shown like 17/02/2020 but what i see in the ListBox is 2/17/2020
Please advise how i alter it so the ListBox matches the format of the worksheet.
VBA Code:
Private Sub ListBox1_Click()
Set sh = Sheets("HONDA SHEET")
sh.Select
Range("C" & ListBox1.List(ListBox1.ListIndex, 3)).Select
Unload PostageItemSoldSearch
End Sub
Private Sub TextBox1_Change()
Dim r As Range, f As Range, Cell As String, added As Boolean
Dim sh As Worksheet
Set sh = Sheets("HONDA SHEET")
sh.Select
With ListBox1
.Clear
.ColumnCount = 4
.ColumnWidths = "240;100;280;50"
If TextBox1.Value = "" Then Exit Sub
Set r = Range("C21", Range("C" & 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 'Item
.List(i, 1) = f.Offset(, 4).Value 'Date
.List(i, 3) = f.Row 'Row Number
.List(i, 2) = f.Offset(, -1).Value 'Customers Name
added = True
Exit For
End Select
Next
If added = False Then
.AddItem f.Value 'Item
.List(.ListCount - 1, 1) = f.Offset(, 4).Value 'Date
.List(.ListCount - 1, 3) = f.Row 'Row Number
.List(.ListCount - 1, 2) = f.Offset(, -1).Value 'Customer Name
End If
Set f = r.FindNext(f)
Loop While Not f Is Nothing And f.Address <> Cell
TextBox1 = UCase(TextBox1)
.TopIndex = 0
Else
MsgBox "NO CUSTOMER WAS FOUND USING THAT INFORMATION", vbCritical, "POSTAGE SHEET CUSTOMER NAME SEARCH"
TextBox1.Value = ""
TextBox1.SetFocus
End If
End With
End Sub