Visual Basic의 콤포박스에 년/월 채우기 소스입니다.

예전에 사용했던 코드인데, 올려봅니다. ㅎㅎ


Private Sub UserForm_Initialize()
    Dim Yr As Long
    Dim Mn As Long
    Dim CurryYear As Long
    Dim iY As Long
    Dim CurrMonth As Long
    Dim CurrYear As Long
    
    CmbMonth.Clear
    For Mn = 1 To 12
        CmbMonth.AddItem Format(Mn, "00")
    Next Mn
    CurryYear = Format(Date, "yyyy")
    Yr = CurryYear - 25
    CurryYear = CurryYear + 25
    
    CmbYear.Clear
    For iY = Yr To CurryYear
        CmbYear.AddItem iY
    Next iY
    
    CurrMonth = Format(Date, "MM")
    CurrYear = Format(Date, "YYYY")
        
    CmbMonth = Format(CurrMonth, "00")
    CmbYear = CurrYear
    
End Sub