(Solved) – Modifying ListBox using VBA

(solved)-–-modifying-listbox-using-vba

I’m very new to VBA and I’ve been trying to find a way to create a date selection drop-down but I haven’t been successful in handling a “February” selection. Here is what I have so far,

If (monthListBox.Value = "Jan" Or monthListBox.Value = "Mar" Or monthListBox.Value = "May" Or monthListBox.Value = "Jul" Or monthListBox.Value = "Aug" Or monthListBox.Value = "Oct" Or monthListBox.Value = "Dec") Then
    If dayCount < 31 Then
        For i = dayCount To 31
            dateComboBox.AddItem (i)
        Next i
    End If
ElseIf (monthListBox.Value = "Apr" Or monthListBox.Value = "Jun" Or monthListBox.Value = "Sep" Or monthListBox.Value = "Nov") Then
    dateComboBox.RemoveItem (30)
    If dayCount < 30 Then
        For i = dayCount To 30
            dateComboBox.AddItem (i)
        Next i
    End If
Else
    If isLeapYear = True Then
        With dateComboBox
            .RemoveItem (30)
            .RemoveItem (29)
        End With
    Else
        dateComboBox.RemoveItem (28)
    End If
End If

Leave a Reply

Your email address will not be published. Required fields are marked *