fill combobox with particular condition

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

fill combobox with particular condition

Post by sal21 »

I need to fill a combobox based the current day - 1 to 30

for example current day=16/07/2022

15/07/2022 (is the current day-1)
16/07/2022
...
14/08/2022

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

Re: fill combobox with particular condition

Post by HansV »

Code: Select all

    Dim d As Date
    For d = Date - 1 To DateAdd("m", 1, Date) - 2
        Me.ComboBox1.AddItem Format(d, "dd/mm/yyyy")
    Next d
Best wishes,
Hans

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

Re: fill combobox with particular condition

Post by sal21 »

HansV wrote:
16 Jul 2022, 09:34

Code: Select all

    Dim d As Date
    For d = Date - 1 To DateAdd("m", 1, Date) - 2
        Me.ComboBox1.AddItem Format(d, "dd/mm/yyyy")
    Next d
great!