TomNR
Member
Hi all,
I currently have a lookup feature built but it takes 15-30 seconds to search through all 11500 rows of data.
I was wondering if there is a quicker method than the one I am using or if it is because of the size of the data it is searching through?
Thanks in advance!
I currently have a lookup feature built but it takes 15-30 seconds to search through all 11500 rows of data.
I was wondering if there is a quicker method than the one I am using or if it is because of the size of the data it is searching through?
Thanks in advance!
Code:
Sub Lookup()
'declare variables
Dim rngFind As Range
Dim strFirstFind As String
'error statement
On Error GoTo errHandler:
'clear the listbox
lstLookup.Clear
'look up parts or all of full name
With Sheet7.Range("A:A")
Set rngFind = .Find(txtLookup.Text, LookIn:=xlValues, lookat:=xlPart)
'if value found then set a variable for the address
If Not rngFind Is Nothing Then
strFirstFind = rngFind.Address
'add the values to the listbox
Do
If rngFind.Row > 1 Then
lstLookup.AddItem rngFind.Value
lstLookup.List(lstLookup.ListCount - 1, 1) = rngFind.Offset(0, 1)
End If
'find the next address to add
Set rngFind = .FindNext(rngFind)
Loop While Not rngFind Is Nothing And rngFind.Address <> strFirstFind
End If
End With
'error block
On Error GoTo 0
Exit Sub
errHandler::
MsgBox "An Error has Occurred " & vbCrLf & "The error number is: " _
& Err.Number & vbCrLf & Err.Description & vbCrLf & _
"Please notify the administrator"
End Sub