Como filtrar en un listbox solo ciertas filas según criterio
Para Dante.
Buenas tardes experto. Anteriormente me había ayudado con este buscador pero ahora quiero actualizarlo. Este buscador al momento de darle al boton buscar por fecha me muestra lo siguiente en el listbox y en los textbox, lo que necesito es que me pueda sumar algo así como sumar. Si. Conjunto que me pueda sumar según la operación de la octava columna ( enganche, contado, abono/pago) y los resultado los muestre como se ven en los siguientes textbox que están de rojo porque actualmente solo aparece con los que esta en números negro. Le agrego la macro y imagen la que tengo actualmente para explicarme mejor. Espero me pueda ayudar.
ListBox1. Clear
ListBox1.ColumnCount = 10
ListBox1.ColumnWidths = "30;100;135;38;38;38;38;55;115;40;"
For Each celda In Hoja4.Range("I2:I" & Hoja4.Range("I" & Rows.Count).End(xlUp).Row)
If celda >= DTPicker1 And celda <= DTPicker2 Then
ListBox1. AddItem
ListBox1. List(ListBox1.ListCount - 1, 0) = Hoja4. Cells(celda.Row, "A") 'documento
ListBox1. List(ListBox1.ListCount - 1, 1) = Hoja4. Cells(celda.Row, "B") 'nombre
ListBox1. List(ListBox1.ListCount - 1, 2) = Hoja4. Cells(celda.Row, "C") 'articulo
ListBox1. List(ListBox1.ListCount - 1, 3) = Hoja4. Cells(celda.Row, "D") 'saldos ant
ListBox1. List(ListBox1.ListCount - 1, 4) = Hoja4. Cells(celda.Row, "E") 'abono
ListBox1. List(ListBox1.ListCount - 1, 5) = Hoja4. Cells(celda.Row, "F") 'saldo a
ListBox1. List(ListBox1.ListCount - 1, 6) = Hoja4. Cells(celda.Row, "G") 'mora
ListBox1. List(ListBox1.ListCount - 1, 7) = Hoja4. Cells(celda. Row, "H") 'forma
ListBox1.List(ListBox1.ListCount - 1, 8) = Hoja4.Cells(celda.Row, "I") & (" ") & Hoja4.Cells(celda.Row, "J") 'fecha y hora
ListBox1.List(ListBox1.ListCount - 1, 9) = Hoja4.Cells(celda.Row, "K") 'usuario
End If
Next
TextBox5.Value = Me.ListBox1.ListCount
'
Dim total, mora, pago As Long
Dim varRow As Integer
For varRow = 0 To (ListBox1.ListCount - 1)
pago = pago + Val(ListBox1.Column(4, varRow))
mora = mora + Val(ListBox1.Column(6, varRow))
Next
TextBox2 = pago
TextBox3 = mora
On Error Resume Next
pago = Val(TextBox2.Value)
mora = Val(TextBox3.Value)
total = pago + mora
TextBox4.Text = total
On Error GoTo 0
'MsgBox "La Busqueda ha Finalizado.", vbInformation, "Atencion Usuario!!!"
End Sub
Respuesta de Dante Amor
1
