Hi,
I would when run the form then will select DEC-24 automatically , if I try select month is not current month then will show message "sorry, the current month is wrong" and should select DEC-24 again.
I would deal with English months as inside the code , because the language is Arabic in my PC .
thanks
I would when run the form then will select DEC-24 automatically , if I try select month is not current month then will show message "sorry, the current month is wrong" and should select DEC-24 again.
I would deal with English months as inside the code , because the language is Arabic in my PC .
VBA Code:
Option Base 1
Private Sub ComboBox1_Change()
If ComboBox1.Value <> Format(ComboBox1, "mmm-yy") Then MsgBox "sorry, the current month is wrong": Exit Sub
End Sub
Private Sub UserForm_Activate()
Dim MonthName As Variant
Dim Yr As Long
MonthName = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
' get last 2 digits of current year
Yr = Right(Year(Date), 2)
Dim i As Integer
' add 12 English months from position in the array
For i = 1 To 12
' append current year to month
Me.ComboBox1.AddItem MonthName(i) & "-" & Yr
Next
End Sub