用提示框输入年份
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