Filtro en Listbox mientras se escribe en textbox
Tengo un problema con este código y espero me puedan ayudar, tengo 50 columnas mostradas en el listbox, pero cuando escribo en el textbox (CC_Nombre) para que haga el filtro en automático si lo hace, pero solo me muestra 10 columnas, ¿me podrían ayudar a decirme que estoy haciendo mal? :( #Help saludos y gracias :D
PD: aprovechando también me podrían ayudar a que la cabecera siempre este visible al hacer el filtro por favor.
Private Sub UserForm_Initialize()
Dim fila As Long
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set b = Sheets("Clientes")
uf = b.Range("A" & Rows.Count).End(xlUp).Row
uc = b.Cells(1, Columns.Count).End(xlToLeft).Address
wc = Mid(uc, InStr(uc, "$") + 1, InStr(2, uc, "$") - 2)
With Me.ListBox1
.ColumnCount = 100
.ColumnWidths = "50 pt;155 pt;60 pt;60 pt;60 pt;50 pt;60 pt"
.RowSource = "Clientes!A1:" & wc & uf
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Private Sub CC_Nombre_Change()
On Error Resume Next
Set b = Sheets("Clientes")
uf = b.Range("A" & Rows.Count).End(xlUp).Row
'-------------v-------------'
'-------NOMBRE TEXBOX-------'
'-------------v-------------'
If Trim(CC_Nombre.Value) = "" Then
'Me.ListBox1.List() = b.Range("A1:AX" & uf).Value
Me.ListBox1.RowSource = "Clientes!A1:AX" & uf
Exit Sub
End If
b.AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 2 To uf
'--------------------v--------------------'
'------CAMBIO DE COLUMNA PARA FILTRO------'
'--------------------v--------------------'
strg = b.Cells(i, 2).Value
If UCase(strg) Like UCase(CC_Nombre.Value) & "*" Then
Me.ListBox1.AddItem b.Cells(i, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = b.Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = b.Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = b.Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = b.Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = b.Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = b.Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = b.Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = b.Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 9) = b.Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 10) = b.Cells(i, 11)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 11) = b.Cells(i, 12)
End If
Next i
Me.ListBox1.ColumnWidths = "50 pt;155 pt;60 pt;60 pt;60 pt;50 pt;60 pt;60 pt;60 pt;60 pt"
End Sub
2 respuestas
Respuesta de Dante Amor
1
Respuesta de James Bond
1

