Excel VBA ComboBox List

837 Views Asked by At

In Excel, I don't know how to specify a default selection in a combobox.

In the following image I have a ComboBox in a user form that is a list of Months (ComboBox1.Value = Format(ComboBox1.Value, "mmm-yy")) from a named range.

enter image description here

Rowsource: Months runs back a year or two, however in the interests of user-sanity, I want the default selection to be the month before the current month e.g. if the current month is January 2016 then I want the default highlight to jump to December 2016 when the combobox is clicked rather than a user needing to scroll to it.

I attempted to force in the following way:

ComboBox1.Text = Text(EoMonth(TODAY(), -1), "MMM-YY"), which should have been sufficent, but it doesn't work, in the ComboBox1_Change() / ComboBox1_Click() private sub below.

Private Sub ComboBox1_Change()
    ComboBox1.Value = Format(ComboBox1.Value, "mmm-yy")

End Sub
0

There are 0 best solutions below