H o l a:
Te anexo todo el código con los cambios:
Dim l2, h2
'
Private Sub cmbEncabezado_Change()
'Cambia el TextBox con cada cambio en el Combo
Me.lblFiltro = "Filtro por " & Me.cmbEncabezado.Value
End Sub
'
Private Sub CommandButton4_Click()
'Por.Dante Amor
Call Filtrar
txtFiltro1.SetFocus
End Sub
'
Private Sub Filtrar()
'Por.Dante Amor
If h2.FilterMode = True Then ActiveSheet.ShowAllData
If txtFiltro1 = "" Then Exit Sub
ListBox1.Clear
col = Me.cmbEncabezado.ListIndex + 1
If col = 0 Then Exit Sub
n = h2.Name
If Contie Then cad = "*" & txtFiltro1 & "*"
If Empiece Then cad = txtFiltro1 & "*"
If Termine Then cad = "*" & txtFiltro1
For i = 2 To h2.Range("A" & Rows.Count).End(xlUp).Row
If UCase(h2.Cells(i, col)) Like UCase(cad) Then
ListBox1. AddItem h2.Cells(i, 1)
ListBox1. List(ListBox1.ListCount - 1, 1) = h2.Cells(i, 2)
ListBox1. List(ListBox1.ListCount - 1, 2) = h2.Cells(i, 3)
ListBox1. List(ListBox1.ListCount - 1, 3) = h2.Cells(i, 4)
ListBox1. List(ListBox1.ListCount - 1, 4) = h2.Cells(i, 5)
ListBox1. List(ListBox1.ListCount - 1, 5) = h2.Cells(i, 6)
ListBox1. List(ListBox1.ListCount - 1, 6) = h2.Cells(i, 7)
ListBox1. List(ListBox1.ListCount - 1, 7) = h2.Cells(i, 8)
ListBox1. List(ListBox1.ListCount - 1, 8) = h2.Cells(i, 9)
ListBox1. List(ListBox1.ListCount - 1, 9) = h2. Cells(i, 10)
End If
Next
End Sub
'
Private Sub txtFiltro1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'mayuscula texto de filtrado
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
'
Private Sub UserForm_Initialize()
'Act.Por.Dante Amor
'Dar formato al ListBox y traer los encabezados de la tabla
Application.ScreenUpdating = False
Call OcultarHojas
Set l1 = ThisWorkbook
Set l2 = Workbooks.Open("maestro de codigos.xlsx")
l1.Activate
'
Set h2 = l2.Sheets("MAESTRO")
For i = 1 To 9
Me.Controls("Label" & i) = h2.Cells(1, i).Value
Next i
'
With Me
.ListBox1.ColumnCount = 9
.ListBox1.ColumnWidths = "56 pt;50 pt;200 pt;40 pt;70 pt;100 pt;60 pt;60 pt;60 pt;50 pt"
.cmbEncabezado.List = Application.Transpose(h2.Range("A1").Resize(1, 9).Value)
.cmbEncabezado.ListStyle = fmListStyleOption
End With
Me.cmbEncabezado.Text = "DESCRIPCION"
Application.ScreenUpdating = True
End Sub
'
Private Sub CommandButton2_Click()
'Cerrar formulario
'ThisWorkbook.Application.Visible = True
'Call Mostrarlibro
l2.Close
Unload Me
End Sub
Sub Mostrarlibro()
Dim Hoja As Worksheet
For Each Hoja In Worksheets
If Hoja.CodeName <> "Hoja1" Then
Hoja.Visible = xlSheetVisible
End If
Next Hoja
End Sub
'
Sub OcultarHojas()
Dim Hoja As Worksheet
For Each Hoja In Worksheets
If Hoja.CodeName <> "Hoja1" Then
Hoja.Visible = xlSheetVeryHidden
End If
Next Hoja
End Sub
':)
':)