这是按日期进行的代码过滤列,仅显示昨天的记录。 我如何修改该代码以显示工作日,所以如果我在星期一运行它,它将显示星期五的记录?有可能吗?
Selection.AutoFilter
ActiveSheet.Range("$F$1:$F$50").AutoFilter Field:=1, Criteria1:=2, _
Operator:=11, Criteria2:=0, SubField:=0
答案 0 :(得分:1)
基于我的区域设置:
Sub qwerty()
Dim datestring As String, d As Date, sr As String
d = Now()
d = d - 1
sr = Format(d, "dddd")
If sr = "Saturday" Then d = d - 1
If sr = "Sunday" Then d = d - 2
datestring = "=" & Format(d, "mm/dd/yyyy")
ActiveSheet.Range("$F$1:$F$50").AutoFilter Field:=1, Criteria1:= _
datestring, Operator:=xlAnd
End Sub
之前:
之后: