Typing is very slow in search box

Paulo H

Board Regular
Joined
Jun 10, 2020
Messages
106
Office Version
  1. 2016
Platform
  1. Windows
Hi

I have created a sheet that searches a price list from the description colulmn and also company column of the price list then puts into the list box

I works fine but typing in the search box Textbox1 is very slow/laggy

I can't seem to speed it up

the code is
VBA Code:
Private Sub TextBox1_Change()
Dim I As Long
Me.TextBox1 = Format(StrConv(Me.TextBox1, vbLowerCase))
Me.ListBox1.Clear
Me.ListBox1.AddItem "Item"
Me.ListBox1.List(0, 2) = "Company"
Me.ListBox1.List(0, 1) = "Description"
Me.ListBox1.List(0, 3) = "Cost"
Me.ListBox1.Selected(0) = True
For I = 2 To Sheets("Prices").Range("D1000").End(xlUp).Row
For X = 1 To Len(Sheets("Prices").Cells(I, 2))
A = Me.TextBox1.TextLength
If LCase(Mid(Sheets("Prices").Cells(I, 2), X, A)) = Me.TextBox1 And Me.TextBox1 <> "" Then
Me.ListBox1.AddItem Sheets("Prices").Cells(I, 1)
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "" & Sheets("Prices").Cells(I, 2)
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = Format(Sheets("Prices").Cells(I, 14), "£#,00.00")

Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "" & Sheets("Prices").Cells(I, 2)
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = "" & Sheets("Prices").Cells(I, 4)
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "" & Sheets("Prices").Cells(I, 16)
ElseIf LCase(Mid(Sheets("Prices").Cells(I, 4), X, A)) = Me.TextBox1 And Me.TextBox1 <> "" Then
Me.ListBox1.AddItem Sheets("Prices").Cells(I, 1)
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = "" & Sheets("Prices").Cells(I, 2)
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = Format(Sheets("Prices").Cells(I, 14), "£#,00.00")
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "" & Sheets("Prices").Cells(I, 2)
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = "" & Sheets("Prices").Cells(I, 4)
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = "" & Sheets("Prices").Cells(I, 16)
End If
Next X
Next I

End Sub
 
Last edited by a moderator:

Paulo H

Board Regular
Joined
Jun 10, 2020
Messages
106
Office Version
  1. 2016
Platform
  1. Windows
Sorted. My fault missed a bit of code sorry

Brilliant much faster
 

Some videos you may like

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Watch MrExcel Video

Forum statistics

Threads
1,122,991
Messages
5,599,242
Members
414,298
Latest member
bongielondy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top