+ Reply to Thread
Results 1 to 3 of 3

Usersform in VBA for Excel

  1. #1
    Guest

    Usersform in VBA for Excel

    I have creted a userform using Visual basic that writes
    into an excel spreadsheet. Within this form I have
    several textboxes.

    Is it possible for me to write some code which will
    ensure that the boxes cannot be left blank when the form
    is submitted and error message is presented telling the
    user to add data to the relevant textboxes

    Many thanks

    Nick Read

  2. #2
    Bob Phillips
    Guest

    Re: Usersform in VBA for Excel


    With Textbox1
    If .Text = "" Then
    MsgBox "Submit data"
    .SetFocus
    End If
    End With

    --
    HTH

    Bob Phillips

    <anonymous@discussions.microsoft.com> wrote in message
    news:03df01c54b17$5a903b60$a401280a@phx.gbl...
    > I have creted a userform using Visual basic that writes
    > into an excel spreadsheet. Within this form I have
    > several textboxes.
    >
    > Is it possible for me to write some code which will
    > ensure that the boxes cannot be left blank when the form
    > is submitted and error message is presented telling the
    > user to add data to the relevant textboxes
    >
    > Many thanks
    >
    > Nick Read




  3. #3
    Stevie_mac
    Guest

    Re: Usersform in VBA for Excel

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    If TextBox3.Text = "" Then TextBox3.SetFocus: Cancel = 1
    If TextBox2.Text = "" Then TextBox2.SetFocus: Cancel = 1
    If TextBox1.Text = "" Then TextBox1.SetFocus: Cancel = 1
    End Sub


    <anonymous@discussions.microsoft.com> wrote in message news:03df01c54b17$5a903b60$a401280a@phx.gbl...
    >I have creted a userform using Visual basic that writes
    > into an excel spreadsheet. Within this form I have
    > several textboxes.
    >
    > Is it possible for me to write some code which will
    > ensure that the boxes cannot be left blank when the form
    > is submitted and error message is presented telling the
    > user to add data to the relevant textboxes
    >
    > Many thanks
    >
    > Nick Read




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1