I have a VARYEAR="2020" (var as String dimensioned) but i can have also 2021, 2019... ecc
i need a looping to retrieve all days number for each month in VARYEAR..
Naturally consider Febrary month (28 or 29 Days)
how to?
looping days in month based year
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: looping days in month based year
Please explain in more detail what you want the code to do.
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: looping days in month based year
pseudo code...
Code: Select all
for i=1 to 12
for x=1 to number of days in current month in i
debug.print number of day
next x
next i
-
- Administrator
- Posts: 78488
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: looping days in month based year
Code: Select all
Sub Test()
Dim VARYEAR As String
Dim i As Long
Dim x As Long
VARYEAR = "2020"
For i = 1 To 12
For x = 1 To Day(DateSerial(VARYEAR, i + 1, 0))
Debug.Print x
Next x
Next i
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 575
- Joined: 14 Nov 2012, 16:06
Re: looping days in month based year
Code: Select all
Sub M_snb()
MsgBox Join([transpose(text(date(2020,1,row(1:365)),"dd-mm-yyyy"))], vbLf)
End Sub