Hola buenos dias perdon por responder tarde, son muchas preguntas que tengo por hacer. Quiero sumar los valores filtrados de por ejemplo ("D" es pago)("E" es mora)("F" es valor total) con macro que me dio anteriormente le agrege lo encerrado con asterisco y no me sale, lo que quiero es el pago la mora y el total en textbox por aparte
Private Sub CommandButton1_Click()
ListBox1.Clear
ListBox1.ColumnCount = 7
ListBox1.ColumnWidths = "55;190;190;70;70;70;80"
For Each celda In Hoja16.Range("G2:G" & Hoja16.Range("G" & Rows.Count).End(xlUp).Row)
If celda >= DTPicker1 And celda <= DTPicker2 Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = Hoja16.Cells(celda.Row, "A")
ListBox1.List(ListBox1.ListCount - 1, 1) = Hoja16.Cells(celda.Row, "B")
ListBox1.List(ListBox1.ListCount - 1, 2) = Hoja16.Cells(celda.Row, "C")
ListBox1.List(ListBox1.ListCount - 1, 3) = Hoja16.Cells(celda.Row, "D")
ListBox1.List(ListBox1.ListCount - 1, 4) = Hoja16.Cells(celda.Row, "E")
ListBox1.List(ListBox1.ListCount - 1, 5) = Hoja16.Cells(celda.Row, "F")
ListBox1.List(ListBox1.ListCount - 1, 6) = Hoja16.Cells(celda.Row, "G")
End If
Next
'***********************
Dim varTotal As Long
Dim varRow As Integer
For varRow = 0 To (ListBox1.ListCount - 1)
varTotal = varTotal + ListBox1.Column(3, varRow)
Next
Private Sub CommandButton1_Click()
ListBox1.Clear
ListBox1.ColumnCount = 7
ListBox1.ColumnWidths = "55;190;190;70;70;70;80"
For Each celda In Hoja16.Range("G2:G" & Hoja16.Range("G" & Rows.Count).End(xlUp).Row)
If celda >= DTPicker1 And celda <= DTPicker2 Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = Hoja16.Cells(celda.Row, "A")
ListBox1.List(ListBox1.ListCount - 1, 1) = Hoja16.Cells(celda.Row, "B")
ListBox1.List(ListBox1.ListCount - 1, 2) = Hoja16.Cells(celda.Row, "C")
ListBox1.List(ListBox1.ListCount - 1, 3) = Hoja16.Cells(celda.Row, "D")
ListBox1.List(ListBox1.ListCount - 1, 4) = Hoja16.Cells(celda.Row, "E")
ListBox1.List(ListBox1.ListCount - 1, 5) = Hoja16.Cells(celda.Row, "F")
ListBox1.List(ListBox1.ListCount - 1, 6) = Hoja16.Cells(celda.Row, "G")
End If
Next
'
Dim Total, Mora, Pago As Long
Dim varRow As Integer
For varRow = 0 To (ListBox1.ListCount - 1)
pago = pago + ListBox1.Column(3, varRow)
mora = mora + ListBox1.Column(4, varRow)
total = total + ListBox1.Column(5, varRow)
Next
TextBox1 = pago
TextBox2 = Mora
TextBox3 = total
MsgBox "La Busqueda ha Finalizado.", vbInformation, "Atencion Usuario!!!"
End Sub
'*******************************
MsgBox "La Busqueda ha Finalizado.", vbInformation, "Atencion Usuario!!!"
End Sub
espero que pueda comprender mi pregunta gracia
dirigido a "Dante Amor"
Hola Dante yo tengo algo similar pero al momento de correr me sale un error? creo que no reconoce la variable celda.el error que sale "run time error:Could not set the list property.Type Mismatch "Me.ListBox1.ClearListBox1.ColumnCount = 2fecha1 = DTPicker1.Valuefecha2 = DTPicker2.Valuefecha1 = Format(DTPicker1.Value, "yyyy-mm-dd")fecha2 = Format(DTPicker2.Value, "yyyy-mm-dd")For Each celda In Sheet23.Range("J5:J" & Sheet23.Range("J" & Rows.Count).End(xlUp).Row) If celda >= DTPicker1 And celda <= DTPicker2 ThenListBox1.AddItemListBox1.List(ListBox1.ListCount - 1, 0) = Sheet23.Cells(celda.Row, "A")ListBox1.List(ListBox1.ListCount - 1, 1) = Sheet23.Cells(celda.Row, "B")EndIf Next - Carlos Vazquez