i have a userform which has 3 textbox to input the shamsi(Persian) date manually to a cell in worksheet. its impotent to input the numbers as date format. But it doesnt work correctly.
i tried to use dateserial function as below:
Dim intDay As Integer
Dim intMonth As Integer
Dim intYear As Integer
Dim rng1 as range
If Me.TextBox43 <> "" Then
rng1.Offset(0, -2).Value = Format(rng1.Offset(0, -2).Value, "[$-fa-IR,16]yyyy/mm/dd;@")
TextBox43 = Format(TextBox43, "[$-fa-IR,16]yyyy;@")
TextBox44 = Format(TextBox44, "[$-fa-IR,16]mm;@")
TextBox45 = Format(TextBox45, "[$-fa-IR,16]dd;@")
intDay = Me.TextBox45
intMonth = Me.TextBox44
intYear = Me.TextBox43
rng1.Offset(0, -2).Value = DateSerial(intYear, intMonth, intDay)
Else
rng1.Offset(0, -2) = (Date)
End If
But it doesnt give a right output. for example for these data: textbox43 = 1402 , textbox44= 01, textbox45=28 it gives me this answer: 1282/05/10 instead of 1402/01/28 . Also when I leave the textboxes empty then date function work correctly and the output is current date. please help me if you could. thanks a lot.