Mostrar datos filtrados en listbox
Tengo el siguiente código que me permite filtrar los datos cargados a un listbox, esta parte funciona casi a la perfección, el detalle esta en que solo muestra 10 columnas y sin encabezado, se que VBA tiene esa limitación al usar el .AddItem, ¿pero existe alguna forma de poder vacilar dicha limitación?, dejo el código para que me puedan ayudar con las 02 inestabilidades que tiene mi proyecto, muchas gracias.
Private Sub ComboBox1_Change()
Application.ScreenUpdating = False
Dim fila, a As Integer
On Error Resume Next
ListBox1.Clear
a = 0
fila = 6
While Sheets("BDDatos").Cells(fila, 4) <> Empty
dato = ComboBox1
'Si el dato de la fila coincide con el combobox carga los registros al listbox
Var = Sheets("BDDatos").Cells(fila, 4)
If Var = dato Then
a = ListBox1.ListCount
ListBox1. AddItem
ListBox1.List(a, 0) = Sheets("BDDatos"). Cells(fila, 1)
ListBox1.List(a, 1) = Sheets("BDDatos"). Cells(fila, 2)
ListBox1.List(a, 2) = Sheets("BDDatos"). Cells(fila, 3)
ListBox1.List(a, 3) = Sheets("BDDatos"). Cells(fila, 4)
ListBox1.List(a, 4) = Sheets("BDDatos"). Cells(fila, 5)
ListBox1.List(a, 5) = Sheets("BDDatos"). Cells(fila, 6)
ListBox1.List(a, 6) = Sheets("BDDatos"). Cells(fila, 7)
ListBox1.List(a, 7) = Sheets("BDDatos"). Cells(fila, 8)
ListBox1.List(a, 8) = Sheets("BDDatos"). Cells(fila, 9)
ListBox1.List(a, 9) = Sheets("BDDatos"). Cells(fila, 10)
ListBox1.List(a, 10) = Sheets("BDDatos"). Cells(fila, 11)
ListBox1.List(a, 11) = Sheets("BDDatos"). Cells(fila, 12)
ListBox1.List(a, 12) = Sheets("BDDatos"). Cells(fila, 13)
ListBox1.List(a, 13) = Sheets("BDDatos"). Cells(fila, 14)
ListBox1.List(a, 14) = Sheets("BDDatos"). Cells(fila, 15)
ListBox1.List(a, 15) = Sheets("BDDatos"). Cells(fila, 16)
ListBox1.List(a, 16) = Sheets("BDDatos"). Cells(fila, 17)
ListBox1.List(a, 17) = Sheets("BDDatos"). Cells(fila, 18)
ListBox1.List(a, 18) = Sheets("BDDatos"). Cells(fila, 19)
ListBox1.List(a, 19) = Sheets("BDDatos"). Cells(fila, 20)
ListBox1.List(a, 20) = Sheets("BDDatos"). Cells(fila, 21)
ListBox1.List(a, 21) = Sheets("BDDatos"). Cells(fila, 22)
ListBox1.List(a, 22) = Sheets("BDDatos"). Cells(fila, 23)
ListBox1.List(a, 23) = Sheets("BDDatos"). Cells(fila, 24)
ListBox1.List(a, 24) = Sheets("BDDatos"). Cells(fila, 24)
ListBox1.List(a, 25) = Sheets("BDDatos"). Cells(fila, 26)
ListBox1.List(a, 26) = Sheets("BDDatos"). Cells(fila, 27)
ListBox1.List(a, 27) = Sheets("BDDatos"). Cells(fila, 28)
ListBox1.List(a, 28) = Sheets("BDDatos"). Cells(fila, 29)
ListBox1.List(a, 29) = Sheets("BDDatos"). Cells(fila, 30)
ListBox1.List(a, 30) = Sheets("BDDatos"). Cells(fila, 31)
ListBox1.List(a, 31) = Sheets("BDDatos"). Cells(fila, 32)
ListBox1.List(a, 32) = Sheets("BDDatos"). Cells(fila, 33)
End If 'Aumento la fila para que pase a la siguiente
fila = fila + 1
Wend
Application.ScreenUpdating = True
End SubCon esto cargo el combo, espero puedan ayudarme, gracias.
Private Sub UserForm_Initialize()
With ListBox1
.ColumnCount = 33
End With
For Each celda In Range("LISTAR")
ComboBox1.AddItem celda.Value
Next celda
End Sub
1 respuesta
Respuesta de Dante Amor
2