• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

User Form

sumit Madaan

New Member
I Need VBA code userform not get closed(cross sign X) till the time value in textbox is empty.

I dont want this code in any command button. i need when user will click on excel, userform display to him on screen and he will not be able to close the userform till the time value in textbox is not entered.

Thanks in advance.


Active Member
Like this?
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If TextBox1 = "" Then
Cancel = True
MsgBox "Time value is a mandatory field", vbCritical, "Error"
End If
End Sub