简体   繁体   English

从系统日期开始的VBA周编号

[英]VBA Week Number from System Date

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! 您可以提供的任何帮助将不胜感激!

VBA VBA

Debug.Print Format(Now, "ww")

FORMULA

=1+INT((TODAY()-(DATE(YEAR(TODAY()),1,2)-WEEKDAY(DATE(YEAR(TODAY()),1,1))))/7)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM