如何在VBA中过滤日期

时间:2015-06-24 15:31:53

标签: excel vba date filter

我有以下代码,我希望用户只需设置一个类似" 22/06 / 2015" 并将该日期转到过滤器。问题是,当我第一年去过滤器时,  然后我检查一年,出现几个月的日子。 (我只是展示了部分代码)

Sub PassaProRelatorio(planilha As Worksheet, nome As String)
Application.ScreenUpdating = False
On Error Resume Next
ActiveSheet.ShowAllData
Dim contaLinha As Integer
Dim array1 As Variant
Dim mes As String
mes = InputBox("Digite até a data que deseja EX: 27/02/2015")
array1 = Array(1, mes)
Sheets("BasePenhoras").Activate
ActiveSheet.Range("$A$1:$DO$80000").AutoFilter Field:=10, Criteria1:=nome
ActiveSheet.Range("$A$1:$DO$80000").AutoFilter Field:=11, Criteria1:= _
    "Concluído"
ActiveSheet.Range("$A$1:$DO$80000").AutoFilter Field:=72, Criteria1:= _
    "Bloqueio"
ActiveSheet.Range("$A$1:$DO$80000").AutoFilter Field:=5, Operator:= _
xlFilterValues, Criteria2:=array1here

1 个答案:

答案 0 :(得分:0)

如果我正确理解您的问题,这会将您的日期更改为您要查找的格式:

Format(DateValue(mes), "yyyy-mm-dd")