Como Hacer un filtrado con RowSource en vba
Como puedo cambiar este código pero utilizando RowSource para hacer filtrado con 5 textBox
Private Sub TextB1_Change()
Call Filtrar
End Sub
Private Sub TextB2_Change()
Call Filtrar
End Sub
Private Sub TextB3_Change()
Call Filtrar
End Sub
Private Sub TextB4_Change()
Call Filtrar
End Sub
Private Sub TextB5_Change()
Call Filtrar
End Sub
Sub Filtrar()
Set h = Sheets("Formulario")
uf = h.Range("A" & Rows.Count).End(xlUp).Row
If h.AutoFilterMode Then h.AutoFilterMode = False
ListBox1.Clear
'Carga los datos de la cabecera en listbox
ListBox1.AddItem
For ii = 0 To 9
ListBox1.List(0, ii) = h.Cells(1, ii + 1)
Next ii
'
For i = 2 To uf
str1 = h.Cells(i, 8).Value
str2 = h.Cells(i, 2).Value
str3 = h.Cells(i, 3).Value
str4 = h.Cells(i, 10).Value
str5 = h.Cells(i, 1).Value
If TextB1.Value = "" Then text1 = str1 Else text1 = TextB1.Value
If TextB2.Value = "" Then text2 = str2 Else text2 = TextB2.Value
If TextB3.Value = "" Then text3 = str3 Else text3 = TextB3.Value
If TextB4.Value = "" Then text4 = str4 Else text4 = TextB4.Value
If TextB5.Value = "" Then text5 = str5 Else text5 = TextB5.Value
If UCase(str1) Like UCase(text1) & "*" And _
UCase(str2) Like UCase(text2) & "*" And _
UCase(str3) Like UCase(text3) & "*" And _
UCase(str4) Like UCase(text4) & "*" And _
UCase(str5) Like UCase(text5) & "*" Then
Me.ListBox1.AddItem h.Cells(i, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = h.Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = h.Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = h.Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = h.Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = h.Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = h.Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = h.Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = h.Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 9) = h.Cells(i, 10)
End If
Next i
End Sub