+ Reply to Thread
Results 1 to 4 of 4

Multiple If Statements for a command button?

  1. #1
    Registered User
    Join Date
    04-15-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2010
    Posts
    10

    Multiple If Statements for a command button?

    So I have 4 text boxes within a userform and the user MUST enter something in each text box. How do I code a data validation so that all 4 textboxes must be filled when I hit the "Next" button?

    My current code:

    Private Sub cmdNext_Click()
    If txtProjectTitle = "" Then
    MsgBox "Please enter Project Title"

    If txtDate.Text = "" Then
    MsgBox "Please enter a date"

    If txtProjectDuration = "" Then
    MsgBox "Please enter Project Duration"

    If txtClientName = "" Then
    MsgBox "Please enter Client Name"

    Else
    frmPriceMaster.Hide
    frmList.Show
    End If
    End Sub

    Currently it gives me a "Block if without end if" error. Can someone help me? Thanks.

  2. #2
    Registered User
    Join Date
    04-15-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple If Statements for a command button?

    Help please

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,107

    Re: Multiple If Statements for a command button?

    You have 3 If and one End IF

    Use ELSE IF instead of IF (after first IF)
    Never use Merged Cells in Excel

  4. #4
    Registered User
    Join Date
    04-15-2012
    Location
    Washington DC
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Multiple If Statements for a command button?

    Thanks, got it!

+ 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