ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
Hi,
I am using the code below.
On my userform in a TextBox i type a value to be found on my worksheet.
All found values then populate my ListBox
Sometimes a common value like FORD FIESTA is used.
My issue is that the search / population can take some time & on occasion the userform vanishes from sight whilst the code is doing its job.
Once done the userform is shown & ListBox is populated.
Can the code be edited so this doesnt happen or do you see an issue in the code that makes it happen.
Thanks
I am using the code below.
On my userform in a TextBox i type a value to be found on my worksheet.
All found values then populate my ListBox
Sometimes a common value like FORD FIESTA is used.
My issue is that the search / population can take some time & on occasion the userform vanishes from sight whilst the code is doing its job.
Once done the userform is shown & ListBox is populated.
Can the code be edited so this doesnt happen or do you see an issue in the code that makes it happen.
Thanks
Rich (BB code):
Private Sub TextBoxSearchColumnC_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 ListBoxFind
.Clear
.ColumnCount = 2
.ColumnWidths = "100;0"
If TextBoxSearchColumnC.Value = "" Then Exit Sub
Set R = Range("C9", Range("C" & Rows.Count).End(xlUp))
Set f = R.Find(TextBoxSearchColumnC.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
TextBoxSearchColumnC = UCase(TextBoxSearchColumnC)
.TopIndex = 0
Else
MsgBox "NO ITEM WAS FOUND USING THAT INFORMATION", vbCritical, "POSTAGE SHEET ITEM SEARCH"
TextBoxSearchColumnC.Value = ""
TextBoxSearchColumnC.SetFocus
End If
End With
Me.ListBoxReplace.List = Me.ListBoxFind.List
End Sub