系统日期中的 VBA 周数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17443709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VBA Week Number from System Date
提问by Conquistador
I was hoping you'd be able to help me out with a bit of code which calculates the Week Number based from the system date.
I have a TextBox WeekNum
, which I want to show the Week Number for when CommandButton1_Click
is activated.
我希望你能用一些代码帮助我解决基于系统日期计算周数的问题。我有一个 TextBox WeekNum
,我想显示CommandButton1_Click
激活时的周数。
I have found articles on how to calculate the Week Number from a given date, but I do not know enough VBA to change this to the system date.
我找到了关于如何从给定日期计算周数的文章,但我不知道足够的 VBA 将其更改为系统日期。
Any help you can offer will be appreciated!
您可以提供的任何帮助将不胜感激!
回答by
VBA
VBA
Debug.Print Format(Now, "ww")
FORMULA
公式
=1+INT((TODAY()-(DATE(YEAR(TODAY()),1,2)-WEEKDAY(DATE(YEAR(TODAY()),1,1))))/7)