H o l a:
Te anexo el código para sumar las deudas y mostrar el total:
Private Sub ComboBox1_Change()
'Act.Por.Dante Amor
NOMBRES = ""
APELLIDOS = ""
If ComboBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = -1 Then Exit Sub
f = ComboBox1.ListIndex + 2
Set h2 = Sheets("DEUDAS CLIENTES")
NOMBRES = h2.Cells(f, "C")
APELLIDOS = h2.Cells(f, "D")
'
Set r = h2.Columns("B")
Set b = r.Find(ComboBox1, lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
'detalle
wtot = wtot + h2.Cells(b.Row, "E")
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
'
'Set h3 = Sheets("PAGO DEUDA CLIENTE")
'Set r = h3.Columns("B")
'Set b = r.Find(ComboBox1, lookat:=xlWhole)
'If Not b Is Nothing Then
' ncell = b.Address
' Do
' wpag = wpga + h3.Cells(b.Row, "F")
' Set b = r.FindNext(b)
' Loop While Not b Is Nothing And b.Address <> ncell
'End If
'DEUDA = wtot - wpag
DEUDA = wtot
End Sub
Aprovecho para comentarte, si quieres el saldo de la persona, entonces tienes que sumar las deudas y restarle los pagos que haya realizado, entonces utiliza la siguiente macro:
Private Sub ComboBox1_Change()
'Act.Por.Dante Amor
NOMBRES = ""
APELLIDOS = ""
If ComboBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = -1 Then Exit Sub
f = ComboBox1.ListIndex + 2
Set h2 = Sheets("DEUDAS CLIENTES")
NOMBRES = h2.Cells(f, "C")
APELLIDOS = h2.Cells(f, "D")
'
Set r = h2.Columns("B")
Set b = r.Find(ComboBox1, lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
'detalle
wtot = wtot + h2.Cells(b.Row, "E")
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
'
Set h3 = Sheets("PAGO DEUDA CLIENTE")
Set r = h3.Columns("B")
Set b = r.Find(ComboBox1, lookat:=xlWhole)
If Not b Is Nothing Then
ncell = b.Address
Do
wpag = wpga + h3.Cells(b.Row, "F")
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
DEUDA = wtot - wpag
'DEUDA = wtot
End Sub