In my code below i have a loop that searches through my database for The First and Last Name of a selected person in the list box and determines that the person selected in a list box is actually the person in the worksheet.
My question is when i get large amounts of data into the spreadsheet will this loop greatly slow excel down. Is there a better way to link a list box to the worksheet??
Column "A" = First Name
Column "B" = Last Name
"X" - returns row number of person
Private Sub rg_btn_add1_Click()
Dim x As Long
Dim filfin As Long
Application.ScreenUpdating = False
filfin = Range("A65536").End(xlUp).Row
With Sheets("Database")
For x = 2 To filfin
If Range("A" & x) = Me.rg_db_list.List(Me.rg_db_list.ListIndex, 0) Then
If Range("B" & x) = Me.rg_db_list.List(Me.rg_db_list.ListIndex, 1) Then
Exit For
End If
End If
Next x
Registration.rg_txt_rider1.Tag = Range("A" & x)
Registration.rg_btn_add1.Tag = Range("B" & x)
Registration.rg_txt_rider1.Value = Registration.rg_txt_rider1.Tag & " " & Registration.rg_btn_add1.Tag
Range("K" & x).Value = "TRUE"
End With
If Registration.rg_txt_rider1.Value > "" Then
If Registration.rg_txt_rider2.Value > "" Then
Registration.rg_btn_done.Enabled = True
End If
End If
rg_refresh_db_list
rg_refresh_rg_list
Application.ScreenUpdating = True
End Sub
Bookmarks