按今天的日期和之后过滤数据 [英] Filter Data by Today's Date and After

查看:40
本文介绍了按今天的日期和之后过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有可追溯到2010年并持续到2029年的数据.我想创建一个宏,该宏仅过滤数据,包括今天的日期和远期.

I have data that goes back to the year 2010 and continues into the year 2029. I want to create a macro that filters the data only including today's date and forward.

我记录了下面的宏,排除了所有日期,直到今天希望它能给我一个很好的起点,但我仍然很迷茫.

I recorded the macro below by excluding all dates until today's hoping that it would give me a good place to start, but I'm still very lost.

为了使事情变得更加复杂,我没有每个可用的日期,因此对于今天的日期使用变量并不总是可行.因此,我想我需要使用宏来排除今天之前的所有内容.

To make it even more complicated, I don't have every single date available to me, so using a variable for today's date won't always work. So I guess I would need the macro to exclude everything before today's date.

感谢您的帮助,我真的迷路了,需要很多帮助.

Thanks for the help, I'm really lost and in need of quite a bit.

 Sub Macro1()

    Sheets("Consulta_Lastro").Range("$B$4:$T$9047").AutoFilter Field:=4, Operator:= _
    xlFilterValues, Criteria2:=Array(0, "7/10/2029", 0, "12/20/2028", 0, "12/20/2027", _
    0, "12/20/2026", 0, "12/20/2025", 0, "12/20/2024", 0, "12/20/2023", 0, "12/20/2022", 0, _
    "12/20/2021", 0, "12/22/2020", 0, "12/22/2019", 0, "12/30/2018", 0, "12/30/2017", 0, _
    "12/30/2016", 1, "2/28/2015", 1, "3/31/2015", 1, "4/30/2015", 1, "5/30/2015", 1, _
    "6/30/2015", 1, "7/31/2015", 1, "8/31/2015", 1, "9/30/2015", 1, "10/30/2015", 1, _
    "11/30/2015", 1, "12/30/2015")
End Sub

推荐答案

尝试一下:

Sheets("Consulta_Lastro").Range("$B$4:$T$9047").AutoFilter _
    Field:=4, Criteria1:=">=" & Date

这将仅显示大于或等于今天的日期的日期.HTH.

This will only show dates greater than or equal to today's date. HTH.

这篇关于按今天的日期和之后过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆