輸入任意一年,自動計算出該年份的天數,月,日,以及某天是周幾。
有沒有一個函式輸入年份后,可以回傳當年有多少天?
uj5u.com熱心網友回復:
描述不好, 我重新描述一下:我輸入2020年,回傳2020年總共有多少天。
uj5u.com熱心網友回復:
用提示框輸入年份Sub test()
Dim s, yearstr
yearstr = InputBox("輸入年份" & Chr(10) & "輸入格式" & Chr(10) & "2013", "當年有多少天")
s = DateDiff("d", yearstr & "/1/1", yearstr & "/12/31")
MsgBox s & "天"
End Sub
在指定單元格輸入年份
Sub test2()
Dim s, s2
s = [a1]
If s = vbNullString Then
MsgBox "請在A1單元格輸入年份"
Else
s2 = DateDiff("d", s & "/1/1", s & "/12/31")
End If
[b1] = s2
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/103609.html
上一篇:python機器學習及實踐
