Filtro de hojas por fechas
Tengo la siguiente macro para filtrar las fechas de dos hojas en un formulario con listbox, al ejecutarlo me muestra lo filtrado pero me salta un error. ¿No se que sera?
Adjunto link del documento https://drive.google.com/open?id=1kyeHeLneC1FFdaUpLH1HqzV_KQNAuGkc

Private Sub btn_Buscar_Click()
Dim Fila, Final As Integer
Me.ListBox1.Clear
Me.ListBox2.Clear
'Mostrar ENTRADAS
items = Hoja6.Range("Compras").CurrentRegion.Rows.Count
For i = 2 To items
' If Hoja6.Cells(i, 2).Value Like Me.txt_Buscar.Value
If CDate(Hoja6.Cells(i, 9).Value) >= CDate(Me.txtFecha1) _
And CDate(Hoja6.Cells(i, 9).Value) <= CDate(Me.txtFecha2) Then
Me.ListBox1.AddItem Hoja6.Cells(i, 9) 'fecha
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = Hoja6.Cells(i, 1) 'codigo
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = Hoja6.Cells(i, 2) 'descripcion
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = Hoja6.Cells(i, 3) 'çantidad
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = Hoja6.Cells(i, 6) 'precio compra
End If
Next i
'Mostrar SALIDAS
items2 = Hoja5.Range("Ventas").CurrentRegion.Rows.Count
For j = 2 To items2
'
If CDate(Hoja5.Cells(j, 15).Value) >= CDate(Me.txtFecha1) _
And CDate(Hoja5.Cells(j, 15).Value) <= CDate(Me.txtFecha2) Then
Me.ListBox2.AddItem Hoja4.Cells(j, 15)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 1) = Hoja5.Cells(j, 1)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 2) = Hoja5.Cells(j, 2)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 3) = Hoja5.Cells(j, 3)
Me.ListBox2.List(Me.ListBox2.ListCount - 1, 4) = Hoja5.Cells(j, 4)
'
End If
Next j
Exit Sub
End Sub
1 respuesta
Respuesta de Abraham Valencia
