1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

  2. 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


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

User Form

Discussion in 'VBA Macros' started by sumit Madaan, Mar 15, 2019 at 11:32 AM.

  1. sumit Madaan

    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.

    ANKUSHRS1 Member

    what do you exactly want to do in excel?
    please give details or sample.
  3. Belleke

    Belleke Active Member

    Like this?
    Code (vb):
    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

Share This Page