我正在尝试计算G列中的日期数量(甚至更好:带标题的列"文档日期")是:
这些是我在excel中使用的公式,但我想只需点击一下即可,因为excel文件是从SAP下载的,每天都会执行新的下载。
=COUNTIF(G:G, ">=" & WORKDAY(TODAY(),-1)-2)
=COUNTIF(G:G,"<=" & WORKDAY(TODAY(),-1)-3) - COUNTIF(G:G, "<=" & WORKDAY(TODAY(),-1)-30)
=COUNTIF(G:G, "<=" & WORKDAY(TODAY(),-1)-30)
我是VBA的新手,无法将其真正翻译为vba代码。
希望你能帮助我。
谢谢!
答案 0 :(得分:0)
的公式应该是
=COUNTIF(G:G, "">="" & WORKDAY(TODAY(),-1)-2)
=COUNTIF(G:G,""<="" & WORKDAY(TODAY(),-1)-3) - COUNTIF(G:G, ""<="" & WORKDAY(TODAY(),-1)-30)
=COUNTIF(G:G, ""<="" & WORKDAY(TODAY(),-1)-30)
例如,如果您希望公式为H1,H2和&amp; H3单元然后是VBA代码
Cells(1, 8).Value = "=COUNTIF(G:G, "">="" & WORKDAY(TODAY(),-1)-2)"
Cells(2, 8).Value = "=COUNTIF(G:G,""<="" & WORKDAY(TODAY(),-1)-3) - COUNTIF(G:G, ""<="" & WORKDAY(TODAY(),-1)-30)"
Cells(3, 8).Value = "=COUNTIF(G:G, ""<="" & WORKDAY(TODAY(),-1)-30)"