H o l a:
Te anexo el código
Private Sub CommandButton1_Click()
If ListBox1.ListIndex < 0 Then
MsgBox "Selecciona un registro"
Exit Sub
End If
With FrmDMultas
.nombre = ListBox1.List(ListBox1.ListIndex, 1)
.Show
End With
End Sub
'
Private Sub TextBox1_Change()
'Por.Dante Amor
ListBox1.Clear
If TextBox1 = "" Then Exit Sub
Set h2 = Sheets("Multas")
u = h2.Range("A" & Rows.Count).End(xlUp).Row
Set r = h2.Range("C3:D" & u)
Set b = r.Find(TextBox1, lookat:=xlPart)
If Not b Is Nothing Then
ncell = b.Address
Do
agregar h2, b.Row, h2.Cells(b.Row, "C")
Set b = r.FindNext(b)
Loop While Not b Is Nothing And b.Address <> ncell
End If
End Sub
'
Private Sub UserForm_Activate()
'Por.Dante Amor
Set h2 = Sheets("Multas")
h2.Cells.EntireColumn.AutoFit
ListBox1.ColumnCount = 4
col = Int(h2.Range("C1").Width) + 1 & ";" & _
Int(h2.Range("D1").Width) + 1 & ";" & _
Int(h2.Range("E1").Width) & "; 0"
ListBox1.ColumnWidths = col
For i = 3 To h2.Range("A" & Rows.Count).End(xlUp).Row
agregar h2, i, h2.Cells(i, "C")
Next
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
' Set h = Sheets("Multas")
' Set r = h.Columns("D")
' Set b = r.Find(nombre, lookat:=xlWhole)
' If Not b Is Nothing Then
' ncell = b.Address
' Do
' 'detalle
' ListBox1.AddItem h.Cells(b.Row, "A")
' ListBox1.List(ListBox1.ListCount - 1, 1) = h.Cells(b.Row, "B")
' ListBox1.List(ListBox1.ListCount - 1, 2) = h.Cells(b.Row, "E")
' Set b = r.FindNext(b)
' Loop While Not b Is Nothing And b.Address <> ncell
' End If
End Sub
'
Sub agregar(h2, fila, dato)
'Por.Dante Amor
For i = 0 To ListBox1.ListCount - 1
If StrComp(ListBox1.List(i), dato, vbTextCompare) = 0 Then
ListBox1.List(i, 2) = Val(ListBox1.List(i, 2)) + h2.Cells(fila, "E")
Exit Sub
End If
Next
ListBox1.AddItem dato
ListBox1.List(ListBox1.ListCount - 1, 1) = h2.Cells(fila, "D")
ListBox1.List(ListBox1.ListCount - 1, 2) = h2.Cells(fila, "E")
ListBox1.List(ListBox1.ListCount - 1, 3) = fila
End Sub
' : )
'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias
' : )