ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,237
- Office Version
- 2007
- Platform
- Windows
Afternoon.
On my usefrorm i search for a name by typing in TextBox8
The results from which are collected from my worksheet are then shown in ListBox1
Please see attached photo
What i would also like is for the Date to be collected from the worksheet & put alongside the name in the ListBox
So it would be like
ANDY JONES 01/05/ 2020
ATLAS BROWN 16/11/2020
ETC ETC
The date is in column A
I have the code in use supplied.
On my usefrorm i search for a name by typing in TextBox8
The results from which are collected from my worksheet are then shown in ListBox1
Please see attached photo
What i would also like is for the Date to be collected from the worksheet & put alongside the name in the ListBox
So it would be like
ANDY JONES 01/05/ 2020
ATLAS BROWN 16/11/2020
ETC ETC
The date is in column A
I have the code in use supplied.
VBA Code:
Private Sub ListBox1_Click()
Range("B" & ListBox1.List(ListBox1.ListIndex, 1)).Select
Unload PostageTransferSheet
End Sub
Private Sub TextBox8_Change()
Dim r As Range, f As Range, Cell As String, added As Boolean
Dim sh As Worksheet
Set sh = Sheets("POSTAGE")
sh.Select
With ListBox1
.Clear
.ColumnCount = 2
.ColumnWidths = "100;0"
If TextBox8.Value = "" Then Exit Sub
Set r = Range("B8", Range("B" & Rows.Count).End(xlUp))
Set f = r.Find(TextBox8.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
TextBox8 = UCase(TextBox8)
.TopIndex = 0
Else
MsgBox "NO CUSTOMER WAS FOUND USING THAT INFORMATION", vbCritical, "POSTAGE SHEET CUSTOMER NAME SEARCH"
TextBox8.Value = ""
TextBox8.SetFocus
End If
End With
End Sub