Hi,
I'd like my UserForm to close after the user hits the OK Button, but only if they've filled in TextBox12 which is a required date format.
My code is below
Many Thanks
David
![]()
Please Login or Register to view this content.
Hi,
I'd like my UserForm to close after the user hits the OK Button, but only if they've filled in TextBox12 which is a required date format.
My code is below
Many Thanks
David
![]()
Please Login or Register to view this content.
If Len(Textbox12.value)>0 then
If Not IsDate(TextBox12.Value) Then
MsgBox "The initiation date you have specified is not valid", vbCritical, "Error message"
Exit Sub
else
'Make Sheet1 Active
Sheets(1).Activate
'Determine EmptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Export Data to worksheet
Cells(emptyRow, 1).Value = NameTextBox.Value
Cells(emptyRow, 2).Value = TextBox25.Value
Cells(emptyRow, 3).Value = PhoneTextBox.Value
Cells(emptyRow, 4).Value = ComboBox3.Value
Cells(emptyRow, 5).Value = ComboBox4.Value
Cells(emptyRow, 6).Value = TextBox1.Value
Cells(emptyRow, 7).Value = TextBox26.Value
Cells(emptyRow, 8).Value = TextBox2.Value
Cells(emptyRow, 9).Value = TextBox3.Value
Cells(emptyRow, 10).Value = TextBox4.Value
Cells(emptyRow, 11).Value = TextBox5.Value
Cells(emptyRow, 13).Value = ComboBox6.Value
Cells(emptyRow, 15).Value = TextBox8.Value
Cells(emptyRow, 16).Value = TextBox9.Value
Cells(emptyRow, 17).Value = ComboBox5.Value
Cells(emptyRow, 18).Value = TextBox11.Value
Cells(emptyRow, 20).Value = TextBox13.Value
Cells(emptyRow, 21).Value = TextBox14.Value
Cells(emptyRow, 22).Value = ComboBox2.Value
Cells(emptyRow, 23).Value = TextBox16.Value
Cells(emptyRow, 31).Value = TextBox24.Value
If IsDate(TextBox12.Value) Then
Cells(emptyRow, 19).Value = DateValue(TextBox12.Value)
Else
Cells(emptyRow, 19).Value = "invalid"
End If
unload me
End If
end if
Works great, thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks