Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50207

Dates in Userform VBA

$
0
0
Hi
In my office web components (Windows 7) I can not find any item that I like to introduce in my UserformVBA for dates (Date and Month). So, I would like to ask you for help to the possible resolution for my problem.
I try to use for month (combobox = cboMonth); for days (textbox = txtDat); and for both information (textbox=txtDat2). This last case is the information that is recorded in the worksheet.
The failure of my attempt, due to the fact that there are month with 30, 31, 28 or 29 days.
I don't know how to overcome this problem. Many thanks to who can give a little help for overcome this.
Below is the code I use, but that does not result:
Private Sub txtDat_Change()
Dim Date, DateMounth As String

Date = txtDat.Value
DateMounth = CboMonth.Value

If txtDat.Value = "" Or txtDat.Value < 32 Then
txtDat2.Value = Date & " " & DateMounth
ElseIf txtDat.Value < 0 Or txtDat.Value > 31 Then
MsgBox ("Days of the Month, Please Introduce from 1 to 31, ")
ElseIf txtDat.Value = "00" Then
txtDat2.Value = "00" & " " & DateMounth
End If
If CboMonth.Value = "FEBRUARY" And txtDat.Value = "" Or txtDat.Value > 29 Then
MsgBox ("Days of the Month February, Please Introduce from 1 to 29, ")
ElseIf CboMonth.Value = "FEBRUARY" Or txtDat.Value = "" Then
txtDat2.Value = Date & " " & DateMounth
End If
End Sub

Viewing all articles
Browse latest Browse all 50207

Trending Articles