Excel VBA中的日期和星期怎么加1 Excel 如何用VBA获取当前日期所在的周数

\u600e\u4e48\u7528EXCEL VBA\u7b97\u4efb\u4f55\u4e00\u5929\u662f\u661f\u671f\u51e0

Sub a()
MsgBox Weekday(Date, vbMonday)
End Sub
\u8fd9\u4e2a\u4ee3\u7801\u53ef\u4ee5\u5f97\u5230\u4eca\u5929\u662f\u661f\u671f\u51e0

date\u662f\u4eca\u5929\u7684\u610f\u601d\uff0c\u53ef\u4ee5\u53d8\u66f4\u4e3a\u5355\u5143\u683c\u5f15\u7528
Sub B()
if [a1]"" then
MsgBox Weekday([a1], vbMonday)
else
msgbox "\u8bf7\u8f93\u5165\u65e5\u671f\u540e\u8fd0\u884c"'
end if
End Sub

\u6216\u8005\u4f60\u8981\u7684\u4e0d\u662f\u6211\u8bf4\u7684\uff0c\u4e5f\u4e0d\u662f\u697c\u4e0a\u8981\u8bf4\u7684\u3002
\u4f60\u60f3\u8868\u8fbe\u7684\u662f\uff0c\u5982\u4f55\u5728EXCEL\u4e2d\u589e\u52a0\u4e00\u4e2a\u65e5\u671f\u63a7\u4ef6\u5427
\u8fd9\u4e2a\u561b\uff0c\u9700\u8981\u4f60\u5728EXCEL\u4e2d\u80fd\u591f\u627e\u5230\u90a3\u4e2a\u65e5\u671f\u63a7\u4ef6\uff0c\u7136\u540e\u518d\u7f16\u5199\u76f8\u5173\u7a0b\u5e8f\u4f7f\u5176\u80fd\u6709\u6548\u4f7f\u7528\u3002\u4e14\u968f\u5355\u5143\u683c\u4f4d\u7f6e\u53d8\u5316\u3002\u662f\u8fd9\u4e2a\u610f\u601d\u5427\uff1f

\u5468\u6570=INT(\uff08now-dateserial\uff08year\uff08now\uff09\uff0c1,1\uff09\uff09/7)
\u5927\u81f4\u5199\u6210\u8fd9\u6837\u5427
\u6709\u4e0d\u61c2\u7684\u518d\u95ee\u6211
\u8fd8\u6709\uff0c\u589e\u52a0\u4e00\u4e2a\u5224\u65adint\uff08now\uff09-dateserial\uff08year\uff08now\uff09\uff0c1,1\uff09\uff09 mod 7\uff0c\u5982\u679c\u4e0d\u80fd\u6574\u9664\uff0c\u8981\u518d\u52a01

Sub test()
    MsgBox Format(Date + 1, "yyyy/mm/dd")  '返回今天的日期加1
    MsgBox Format(Date + 1, "aaaa")  '返回今天的星期加1
End Sub


扩展阅读:vba编程入门教程 ... excel vba范例讲解 ... excel vba实例详解 ... excel vba范例大全 ... 初学vba编程100个代码 ... excel vba 多条件查询 ... excel vlookup用法 ... excel vba基础入门 ... excel vba编程教程完整版 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网