如何在VBA中过滤日期

时间:2023-01-24 20:25:54

I have the following code, and I want the user to just set a date like "22/06/2015" and have that date go to a filter. The problem is that when I go to filter I have at first year, then I check a year, appears the months then the days. (I'm just showing a part of the code)

我有以下代码,我希望用户只需设置“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 个解决方案

#1


0  

This will change your date to the format you are looking for if i understand your problem correctly:

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

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

#1


0  

This will change your date to the format you are looking for if i understand your problem correctly:

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

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