In an user form I have a text box for month and a text box for year. I need to check and see if there is a value in each of these before going on with the rest of the code.
My if statement for the MyMonth works, but not the MyYear check. I get the "error Type mismatch '13'."
Here is the first part of my code.
Any ideas?!?
Private Sub cmdAdd_Click()
Dim ws As Worksheet, MyYear As Variant, MyMonth As String
Dim MyRow As Long, MyCol As Integer
Dim response As Integer
Set ws = Worksheets("Data")
MyMonth = Me.MyMonth
If MyMonth = "" Then
MsgBox "Please enter a Month!", vbYes, "Month"
GoTo Last2
Else
MyYear = Me.MyYear
If IsNull(MyYear) Then
MsgBox "Please enter a Year", vbYes, "Month"
Else
My.Year = CInt(Me.MyYear)
My if statement for the MyMonth works, but not the MyYear check. I get the "error Type mismatch '13'."
Here is the first part of my code.
Any ideas?!?
Private Sub cmdAdd_Click()
Dim ws As Worksheet, MyYear As Variant, MyMonth As String
Dim MyRow As Long, MyCol As Integer
Dim response As Integer
Set ws = Worksheets("Data")
MyMonth = Me.MyMonth
If MyMonth = "" Then
MsgBox "Please enter a Month!", vbYes, "Month"
GoTo Last2
Else
MyYear = Me.MyYear
If IsNull(MyYear) Then
MsgBox "Please enter a Year", vbYes, "Month"
Else
My.Year = CInt(Me.MyYear)