Tom’s Tutorials For Excel: Populating a ComboBox For a Range of Years

Tom’s Tutorials For Excel: Populating a ComboBox For a Range of Years

This populates a UserForm ComboBox with years that start 10 years ago and end 10 years from now. The idea is to reasonably control the available year which a user can select. At each passing new year the code will adjust the relative list.

Private Sub UserForm_Initialize()
Dim i%, j%
j = Format(Date, "YYYY")
For i = 1 To 21
ComboBox1.AddItem j - 10
j = j + 1
Next i
End Sub
Share Button
Posted in Tom's Tutorials for Excel
Tags: , , , , , , , , , , , , ,

Leave a Reply

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

*