VBA:应用文字时如何考虑WEEKNUM 2019值

时间:2018-07-10 16:15:12

标签: excel vba excel-vba week-number

我有一列记录WEEKNUM周(本周为第28周),然后,如果该值小于本周,则将其标记为“ Late”。该代码可以正常工作,但是比本周少的几个星期是在2019年。我在下面提供了示例图片,以展示我在做什么。我不确定如何调整VBA以考虑2019年的值。

With isum.workSheets("Orders")
With .Range(.Cells(2, "X"), .Cells(.Rows.Count, "O").End(xlUp).Offset(0, 9))
    .Formula = "=weeknum(o2)"
    .NumberFormat = "0_)"
    .FormatConditions.Delete
    With .FormatConditions.Add(Type:=xlExpression, Formula1:="=x2<weeknum(today())")
        .NumberFormat = "L\at\e_)"
    End With
End With

结尾为

The WEEKNUM formula is applied to the receiving date

1 个答案:

答案 0 :(得分:1)

尝试

...
... , Formula1:="=and(x2<weeknum(today()), year(o2)=year(today()))")
...