Anexo las macros para completar la respuesta.
Public campo1, campo2
Private Sub Image2_Click()
UserForm2.Show
End Sub
Private Sub TextBox1_Change()
If IsNumeric(TextBox1) Then
campo1 = Me.TextBox1.Value
Else
campo1 = Me.TextBox1.Text & IIf(Me.TextBox1.Text = "", "", "*")
End If
filtrar
End Sub
Private Sub TextBox2_Change()
If IsNumeric(TextBox2) Then
campo2 = Me.TextBox2.Value
Else
campo2 = Me.TextBox2.Text & IIf(Me.TextBox2.Text = "", "", "*")
End If
filtrar
End Sub
Sub filtrar()
Application.ScreenUpdating = False
ActiveWorkbook.Worksheets("filtro").Visible = True
Sheets("filtro").Cells.Clear
For Each h In Worksheets
Select Case h.Name
Case "Búsqueda", "filtro"
Case Else
With Sheets(h.Name)
With .Range("A5:F" & .Range("A" & Rows.Count).End(xlUp).Row)
If campo1 <> "" Or campo2 <> "" Then
If campo1 <> "" Then .AutoFilter Field:=2, Criteria1:=campo1
If campo2 <> "" Then .AutoFilter Field:=4, Criteria1:=campo2
.Copy Sheets("filtro").Range("A1")
Else
Sheets("filtro").Cells.Clear
Me.ListBox1 = ""
End If
End With
If .AutoFilterMode Then .Range("A1").AutoFilter
End With
With Sheets("filtro")
uf = .Range("A" & .Rows.Count).End(xlUp).Row
If uf < 2 Then uf = 2
.Columns("A:F").EntireColumn.AutoFit
ancho = Int(.Range("A1").Width + 5) & ";" & Int(.Range("B1").Width + 5) & ";" & _
Int(.Range("C1").Width + 5) & ";" & Int(.Range("D1").Width + 5) & ";" & _
Int(.Range("E1").Width + 5) & ";" & Int(.Range("D1").Width + 5)
tot = Application.Sum(.Range(.Cells(2, "F"), .Cells(uf, "F")))
End With
'uf = Sheets("filtro").Range("A" & Rows.Count).End(xlUp).Row
With Me.ListBox1
.RowSource = ""
.ColumnCount = 6
.RowSource = "filtro!A2:F" & uf
.ColumnHeads = True
.ColumnWidths = ancho
End With
TextBox3 = Format(tot, "$ #,##0.00")
End Select
Next
ActiveWorkbook.Worksheets("filtro").Visible = xlVeryHidden
Application.ScreenUpdating = True
End Sub