我有一个代码可以在excel vba中的两个日期之间进行过滤。问题是自动过滤器似乎忽略了最小日期,只显示小于最大日期的日期作为输出。请在下面找到过滤器代码。谢谢你的帮助
ddate1 = UserForm4.DTPicker1.Value
ddate2 = UserForm4.DTPicker2.Value
If ddate1 >= ddate2 Then
MsgBox " Your start value is wrong", vbInformation, "Notification"
Exit Sub
Else
Sheets(1).Select
Sheets(1).Range(Cells(7, 2), Cells(m, 2)).AutoFilter
Sheets(1).Range(Cells(7, 2), Cells(m, 2)).AutoFilter Field:=1, _
Criteria1:=">=" & Application.Min(ddate1, ddate2), _
Operator:=xlAnd, _
Criteria2:="<=" & Application.Max(ddate1, ddate2)
End If