Fitrado rápido 2018

CODIGO VBA

Private Sub txtCod_Change()
If txtCod = "" Then
 Hoja1.AutoFilterMode = False
Else
 If Hoja1.AutoFilterMode = True Then
 Hoja1.AutoFilterMode = False
 End If
 ActiveSheet.ListObjects("Tabla1").Range.AutoFilter Field:=1, Criteria1:=txtCod.Value, Operator:=xlFilterValues
End If
End Sub

Private Sub txtCod_GotFocus()
On Error Resume Next
Hoja1.AutoFilterMode = False
Hoja1.AutoFilter.ShowAllData
txtPre = Empty: txtProd = Empty
End Sub

Private Sub txtPre_Change()
If txtPre = "" Then
 Hoja1.AutoFilterMode = False
Else
 If Hoja1.AutoFilterMode = True Then
 Hoja1.AutoFilterMode = False
 End If
 ActiveSheet.ListObjects("Tabla1").Range.AutoFilter Field:=3, Criteria1:=txtPre.Value, Operator:=xlFilterValues
End If
End Sub

Private Sub txtPre_GotFocus()
On Error Resume Next
Hoja1.AutoFilterMode = False
Hoja1.AutoFilter.ShowAllData
txtProd = Empty: txtCod = Empty
End Sub

Private Sub txtProd_Change()
If txtProd = "" Then
 Hoja1.AutoFilterMode = False
Else
 If Hoja1.AutoFilterMode = True Then
 Hoja1.AutoFilterMode = False
 End If
 ActiveSheet.ListObjects("Tabla1").Range.AutoFilter Field:=2, Criteria1:="*" & txtProd.Value & "*", Operator:=xlFilterValues
 
End If
End Sub

Private Sub txtProd_GotFocus()
On Error Resume Next
Hoja1.AutoFilterMode = False
Hoja1.AutoFilter.ShowAllData
txtCod = Empty: txtPre = Empty
End Sub

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *