In my userfield I have 2 textboxes for dates; if one of them is empty I want an error message to notify the user that they have to enter dates in both textboxes before continuing. I tried:
If IsEmpty(UserForm1.TextBox2.Value) And Not IsEmpty(UserForm1.TextBox3.Value) Or IsEmpty(UserForm1.TextBox3.Value) And Not IsEmpty(UserForm1.TextBox2.Value) Then
MsgBox "Please fill both date fields", vbInformation, "Date Range Error"
End If
before my next steps in the macro but nothing happens.
Private Sub CommandButton1_Click()
If IsEmpty(UserForm1.TextBox2.Value) And Not IsEmpty(UserForm1.TextBox3.Value) Or IsEmpty(UserForm1.TextBox3.Value) And Not IsEmpty(UserForm1.TextBox2.Value) Then
MsgBox "Please fill both date fields", vbInformation, "Date Range Error"
End If
If UserForm1.ComboBox1.Value = "(Blank)" Then
Sheets("FormResults").Range("C5").ClearContents 'Clear Product Type
Else
Sheets("FormResults").Range("C5").Value = UserForm1.ComboBox1.Value 'Replace Product Type
End If
Sheets("FormResults").Range("C4").Value = UserForm1.TextBox1.Value 'Replace Store
Sheets("FormResults").Range("C3").Value = UserForm1.TextBox2.Value 'Replace Start Date
Sheets("FormResults").Range("D3").Value = UserForm1.TextBox3.Value 'Replace End Date
Unload Me
End Sub