Como agilizar la carga de datos en listbox (15,000 datos)
Tengo una base de datos de aproximadamente 15,000 datos registrados
El cual con ayuda de un código.. Que a continuación anexo
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
TextBox1.Value = UCase(TextBox1) 'cambiar # de textbox
Set b = Sheets("BASE_ENTRADA")
uf = b.Range("A" & Rows.Count).End(xlUp).Row 'LA COLUMNA A ES EL FOLIO
Me.ListBox1.RowSource = ""
With ListBox1
.ColumnCount = 17 ' NUMERO DE COLUMNAS
.List = Range("B1:S1").Value ' ENCABEZADOS DEL RANGO
.ColumnWidths = "50 pt;90 pt;110 pt;70 pt;70 pt;100 pt;70 pt;70 pt;70 pt;70 pt;70 pt;90 pt;100 pt;1 pt;110 pt;70 pt;70 pt;60 pt" 'asignando ancho de columnas
.Clear
For i = 2 To b.Range("B1").End(xlDown).Row 'FILA DE ENCABEZADOS cliente
'
strg = b.Cells(i, 1).Value 'cambiar # de columna a buscar EN ESTE CASO EL 1 ES EL NOMBRE
If UCase(strg) Like "*" & UCase(TextBox1.Value) & "*" Then 'cambiar # de textbox
. AddItem
. List(.ListCount - 1, 0) = b. Cells(i, 1) ' FOLIO
. List(.ListCount - 1, 1) = b. Cells(i, 2) ' FECHA
. List(.ListCount - 1, 2) = b. Cells(i, 3) ' EMISOR
. List(.ListCount - 1, 3) = b. Cells(i, 4) ' CONCEPTO1
. List(.ListCount - 1, 4) = b. Cells(i, 5) ' CLAVE
. List(.ListCount - 1, 5) = b. Cells(i, 6) ' PRODUCTO
. List(.ListCount - 1, 6) = b. Cells(i, 7) ' CANTIDAD
.List(.ListCount - 1, 7) = Format(b.Cells(i, 8), "$#,##0.00") ' P/U
.List(.ListCount - 1, 8) = Format(b.Cells(i, 9), "$#,##0.00") ' IMPORTE
. List(.ListCount - 1, 9) = b. Cells(i, 10) ' RECEPTOR
. List(.ListCount - 1, 10) = b. Cells(i, 11) ' CONCEPTO2
. List(.ListCount - 1, 11) = b. Cells(i, 12) ' USUARIO
. List(.ListCount - 1, 12) = b. Cells(i, 13) ' TIPO DE MOVIMIENTO
. List(.ListCount - 1, 13) = b. Cells(i, 14) '
. List(.ListCount - 1, 14) = b. Cells(i, 15) ' OBSERVACIONES
. List(.ListCount - 1, 15) = b. Cells(i, 16) ' FOLIO O REPARTIDOR
. List(.ListCount - 1, 16) = b. Cells(i, 17) ' VENDEDOR O ENCARGADO
. List(.ListCount - 1, 17) = b. Cells(i, 18) ' UNIDAD DE MEDIDA
End If
Next i
End With
If ListBox1.ListCount > 0 Then
TextBox2.Value = Empty
TextBox3.Value = Empty
TextBox4.Value = Empty
TextBox5.Value = Empty
Else
MsgBox "Si No Se Encuentra El FOLIO " & TextBox1.Value & " Puede Ser Por: 1.- No Hay Datos Registrados " & vbCr & " O 2.- La Busqueda Es Incorrecta. Intenta de Nuevo", vbExclamation, "INFORMACIÓN UTIL"
''TextBox1.Value = Empty
End If
Me.ListBox1.ColumnWidths = "50 pt;90 pt;110 pt;70 pt;70 pt;100 pt;70 pt;70 pt;70 pt;70 pt;70 pt;90 pt;100 pt;1 pt;110 pt;70 pt;70 pt;60 pt"
End Subcoloco una letra en el textbox 1 y me busca por medio de comodin.. Todos lo datos que existan y tenga esa letra... Entre mas letras coloque y haya concidencia se va filtrando...
hasta aqui todo excelente...
El detalle que al borrar el dato colocado en textbox1... Este cargara todos los 15,000 datos en la lista...
El cual no estaría del todo mal
Pero tarda mucho + demasiado en cargar los datos...
¿Me pueden apoyar en mejor el código o donde estoy fallando?
Tarda un poco al buscar el dato con el comodín.. Pero al borrar el dato del textbox1 tarda mucho más porque carga los 15,000 datos y eso que la base seguirá creciendo...
2 Respuestas
Respuesta de Dante Amor
2
Respuesta de Programar Excel
1
