combobox populated with dates


Active Member
Jul 30, 2010
Is there a way to populate a userform combobox with the dates within a month or a date range?

Example1: user wants a list of all the dates in the month of February 2012. Combobox would be filled with the date range 2/1/12 - 2/29/12, one list item for each day.

Example2: user wants a list of all the dates within the range 2/1/12 - 3/31/12. Combobox would be filled with the date range 2/1/12 - 3/31/12, one list item for each day.

If anyone knows of a way to do something like one of the examples above I would love to know how. A way to do example1 would be great, but my project would work better with example2.


Well-known Member
Nov 28, 2011
If user enters their date range with beginning date in B1 and ending date in B2, enter these formulas:
In C1: =B1
In C2 and copy down: =IF(C1="","",IF(C1+1>B$2,"",C1+1))
The input range of the format control of the combo box would be C1 thru as far as you want to allow in the combo box.


Active Member
Jan 19, 2010
Assuming that on your userform you have 2 text boxes for date range begin/end (called TextBox1 and TextBox2), a command button (called CommandButton1) and the combobox called Combobox1, this commandbutton_click event should work. I'd advise more meaningful control names, though.

Private Sub CommandButton1_Click()
    Dim d                               As Date
    If IsDate(Me.TextBox1.Value) And IsDate(Me.TextBox2.Value) Then
        'break comparison to two if statements so we don't have to
        'worry about non-date values throwing an error on a > comparison
        If Me.TextBox2.Value > Me.TextBox1.Value Then
            For d = Me.TextBox1.Value To Me.TextBox2.Value
                ComboBox1.AddItem d
            Next d
            ComboBox1.ListIndex = 0
            MsgBox ("end date must be after begin date")
        End If
        MsgBox ("Please enter valid dates")
    End If
End Sub

Forum statistics

Latest member

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...