Mostrar y contar entradas en la tabla filtrada hasta hoy a través de EXCEL VBA

Mostrar y contar entradas en la tabla filtrada hasta hoy a través de EXCEL VBA

Como dice el título, estoy intentando usar un filtro a través de VBA para ocultar todas las entradas de fecha de una tabla filtrada que están en el futuro y contarlas, pero el código simplemente no funciona de ninguna manera.

Mi enfoque actual es el siguiente:


Dim wbkPlanning As Workbook
Dim wksPlanning As Worksheet
Dim FilterValue as Integer

Workbooks.Open (.... Some Path...) 'this works as i have several other Autofilters in this macro that do the job just fine)

Set wbkPlanning = Workbooks("NAMEOFWORKBOOK.xlsx")
Set wksPlanning = wbkPlanning.Worksheets("NameOfWorksheet")

wksPlanning.Range("$A$4:$AS$600").AutoFilter Field:=24, Criteria1:="=<" & CDbl(Date)

FilterValue = wksPlanning.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count - 1

MsgBox FilterValue

Cuando configuro el filtro manualmente en la hoja de trabajo, los resultados están bien, pero cuando lo configuro así obtengo cero resultados.

Estoy un poco perplejo y realmente agradecería algunos consejos.

¡Gracias!

Respuesta1

Un filtro diferente en la hoja de trabajo impidió que el filtro de fecha mostrara el resultado correcto. Los criterios CDbl(Fecha) funcionaron.

información relacionada