Userform para subtotales en excel 2016

Buscando en internet encontré un user form de tu autoría

Con este código:

Private Sub CommandButton1_Click()
'Por.Dante Amor
'filtra por fechas y subtotales por vendedor
'
Set h1 = Sheets("Hoja1") 'cambiar por el nombre de tu hoja
Set h2 = Sheets("temp") 'hoja temporal
h2.Cells.ClearContents
If h1.AutoFilterMode Then h1.AutoFilterMode = False
ListBox1.RowSource = ""
If TextBox1.Value = "" Then
MsgBox "Captura una Fecha 'Inicio'"
Exit Sub
End If
fec1 = CDate(TextBox1.Value)
If TextBox2 = "" Then
fec2 = fec1
Else
fec2 = CDate(TextBox2.Value)
End If
'
h1.Rows(1).Copy h2.Rows(1)
u = h1.Range("C" & Rows.Count).End(xlUp).Row
j = 2
For i = 2 To u
If h1.Cells(i, "C").Value >= fec1 And h1.Cells(i, "C") <= fec2 Then
Set b = h2.Columns("A").Find(h1.Cells(i, "A"), lookat:=xlWhole)
If Not b Is Nothing Then
h2.Cells(b.Row, "B") = h2.Cells(b.Row, "B") + h1.Cells(i, "B")
Else
u2 = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
h2.Cells(u2, "A") = h1.Cells(i, "A")
h2.Cells(u2, "B") = h1.Cells(i, "B")
End If
End If
Next
u2 = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
ListBox1.RowSource = h2.Name & "!" & h2.Range("A2:B" & u2).Address
End Sub

--------------------

Necesito algo similar para calcular subtotales en una tabla de nombre "Deudas" y de manera que no tenga que elegir entre dos fechas, si no que se pueda elegir un cliente del listado de cliente de la tabla para el filtro, ¿me puedes ayudar con eso?

Añade tu respuesta

Haz clic para o