LIST DAYS

User avatar
sal21
PlatinumLounger
Posts: 4515
Joined: 26 Apr 2010, 17:36

LIST DAYS

Post by sal21 »

Based the month(date) and year(date), how to list the days of a block of 3 month...for example:


month(date) August
year(date) 2022

list the days of

August
September
October

01/08/2022
...
30/10/2022

===============

month(date) January
year(date) 2022

list the days of

January
February
March

01/01/2022
...
31/03/2022

User avatar
HansV
Administrator
Posts: 79526
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: LIST DAYS

Post by HansV »

Do you want to input the month by its name (August or Agosto), or by its number (8)?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4515
Joined: 26 Apr 2010, 17:36

Re: LIST DAYS

Post by sal21 »

HansV wrote:
10 Aug 2022, 14:45
Do you want to input the month by its name (August or Agosto), or by its number (8)?
its number

User avatar
HansV
Administrator
Posts: 79526
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: LIST DAYS

Post by HansV »

Perhaps you can use this as a starting point.

Code: Select all

Sub ListDates()
    Dim ANNO As Long
    Dim MESE As Long
    Dim DATO As Date
    ANNO = 2022
    MESE = 8
    For DATO = DateSerial(ANNO, MESE, 1) To DateSerial(ANNO, MESE + 3, 0)
        ' Do something with DATO, for example
        Debug.Print DATO
    Next DATO
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4515
Joined: 26 Apr 2010, 17:36

Re: LIST DAYS

Post by sal21 »

HansV wrote:
10 Aug 2022, 14:59
Perhaps you can use this as a starting point.

Code: Select all

Sub ListDates()
    Dim ANNO As Long
    Dim MESE As Long
    Dim DATO As Date
    ANNO = 2022
    MESE = 8
    For DATO = DateSerial(ANNO, MESE, 1) To DateSerial(ANNO, MESE + 3, 0)
        ' Do something with DATO, for example
        Debug.Print DATO
    Next DATO
End Sub
:clapping: