英文:
filter for date values in a table
问题
I have this sub:
Sub standardfilter()
Dim ws As Worksheet
Dim tbl As ListObject
Set ws = ActiveSheet
Set tbl = ws.ListObjects("Tabelle1")
tbl.Range.AutoFilter field:=2, Criteria1:=">=Date()", Operator:=xlAnd
Range("Tabelle1").Sort Key1:=Range("E5"), Order1:=xlAscending, Header:=xlYes
End Sub
这是您提供的代码部分的翻译。
英文:
I have this sub:
Sub standardfilter()
Dim ws As Worksheet
Dim tbl As ListObject
Set ws = ActiveSheet
Set tbl = ws.ListObjects("Tabelle1")
tbl.Range.AutoFilter field:=2, Criteria1:=">=Date()", Operator:=xlAnd
Range("Tabelle1").Sort Key1:=Range("E5"), Order1:=xlAscending, Header:=xlYes
End Sub
which is connected to a command button which when executed should first filter for dates which are today or in the future and then filter another date column in ascending order. The problem is that there is no data shown if I only execute the first filter with Criteria1:=">=Date()"
whereby there is data from today or in the future.
The excel table looks like this:
"Gremium" is the event name "Gremientermin" the event's date and "Frist" is the date for a specific work flow within the process for that event.
答案1
得分: 5
tbl.Range.AutoFilter field:=2, Criteria1:=">=" & CLng(Date), Operator:=xlAnd
英文:
Use
tbl.Range.AutoFilter field:=2, Criteria1:=">=" & CLng(Date), Operator:=xlAnd
In this case the date is converted to its numeric equivalent - which is recognized as criteria independent of the systems language
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论