Home > other >  How EXCEL VBA is obtained by year month, day, and that is a few
How EXCEL VBA is obtained by year month, day, and that is a few

Time:10-02

Enter any year, automatically calculates the number of days of the year, month, day, and one day is the week several,
Is there a function input after a year, can return to that year how many days?

CodePudding user response:

Description is not good, I again to describe:
I type in 2020, returned to a total of 2020 days,

CodePudding user response:

With prompt box input year
Sub test ()
Dim s, yearstr
Yearstr=InputBox (" input date "& amp; CRH (10) & amp; "Input format" & amp; CRH (10) & amp; "2013", "then how many days")
S=DateDiff (" d ", yearstr & amp; "/1/1", yearstr & amp; "/12/31")
MsgBox s & amp; "Day"
End Sub
In the specified year cell input
Sub test2 ()
Dim s, s2
S=[a1]
If s=vbNullString Then
MsgBox "please enter a year in cell A1"
The Else
S2=DateDiff (" d ", "s & amp; "/1/1," s & amp; "/12/31")
End the If
(b1)=s2
End Sub