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

标签 vba excel week-number

我有一列记录了 WEEKNUM 周(本周是第 28 周),然后如果该值小于本周,则将其标记为“迟到”。代码运行良好,但比这周少的一些周是在 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

最佳答案

尝试,

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

关于VBA:如何在应用文本时考虑 WEEKNUM 2019 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51269998/

相关文章:

vba - 在 VBA 中获取当前内存配置的最佳方法

sql - 在不使用 LIMIT 的情况下从每个 ID 获取最后 5 条记录

php - 如何计算一年是否有53周

c# - 从日期时间获取周数

excel - 为什么 "Range(...).End(xlDown).Row"返回 1048576?

excel - 如何选择包含数据但列 C 到 L 的最后一行

excel - Excel Range 奇怪行为的 SpecialCells 方法

excel - 使用 1900 年之前的日期在 Excel 电子表格中进行计算

1 月和 12 月日期的 Postgresql 周数相同

.net - 使用 NetOffice 互操作时,无法将 excel 对象作为参数从 VBA 传递到 .NET