+ Reply to Thread
Results 1 to 3 of 3

Help with VBA. Block If without End If

  1. #1
    Registered User
    Join Date
    10-11-2016
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    1

    Help with VBA. Block If without End If

    Hi! I am Xavier and I'm rather new to excel. Recently at my internship, I am tasked to do up a user form without having help from my superiors. I went online to get a Template and started working on it. However, I am stuck at debuging a certain portion of the codes and keep getting compile error: Block if without end.

    ' Check all the data(except remarks field) has entered are not on the userform
    Sub Data_Validation()
    If txtAgn = "" Then
    MsgBox "Enter Name!", vbInformation, "Agency Name"
    Exit Sub
    If txtIATA = "" Then
    MsgBox "Enter Code!", vbInformation, "Agency IATA Code"
    Exit Sub
    If txtNOS = "" Then
    MsgBox "Enter Name!", vbInformation, "Staff Name"
    Exit Sub
    If txtStaffd = "" Then
    MsgBox "Enter designation", vbInformation, "Staff Designation"
    Exit Sub
    If txtEAddr = "" Then
    MsgBox "Enter Address", vbInformation, "Email Address"
    Exit Sub
    If txtCNum = "" Then
    MsgBox "Enter Number!", vbInformation, "Contact Number"
    Exit Sub
    If txtDate = "" Then
    MsgBox "Enter Date", vbInformation, "Date"
    Exit Sub
    If txtPNR = "" Then
    MsgBox "Enter PNR", vbInformation, "PNR"
    Exit Sub
    If txtfgtno = "" Then
    MsgBox "Enter Number!", vbInformation, "Flight Number"
    Exit Sub
    If txtfgtd = "" Then
    MsgBox "Enter date", vbInformation, "Flight Date"
    Exit Sub
    If txtItinerary = "" Then
    MsgBox "Enter itinerary", vbInformation, "Itinerary"
    Exit Sub
    If txtnoseats = "" Then
    MsgBox "Enter Number!", vbInformation, "Number of Seats"
    Exit Sub
    If TxtDAPP = "" Then
    MsgBox "Enter Amount", vbInformation, "Deposit Ammount Per Pax"
    Exit Sub
    If txtTDA = "" Then
    MsgBox "Enter Amount!", vbInformation, "Total Deposit Ammount"
    Exit Sub
    Else
    BlnVal = 1
    End If
    End Sub

    I dont know where or what is wrong with the coding, can someone please highlight and correct my errors. Thank you
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,689

    Re: Help with VBA. Block If without End If

    The structure:
    Please Login or Register  to view this content.
    is called a block if. It needs an End If. You have fourteen of them:
    Please Login or Register  to view this content.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Last edited by protonLeah; 10-11-2016 at 09:52 PM.
    Ben Van Johnson

  3. #3
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,689

    Re: Help with VBA. Block If without End If

    double post

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Block If without End If
    By Oilfield in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-14-2015, 02:51 PM
  2. New kid on the block
    By firsttimer in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 05-20-2015, 05:26 PM
  3. [SOLVED] Block If without End If
    By katieshields in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-30-2014, 08:14 AM
  4. Hi, new kid on the block here!
    By marqz in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-23-2013, 02:06 PM
  5. Replies: 5
    Last Post: 10-09-2012, 10:44 AM
  6. End if without If Block
    By cbh35711 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-12-2012, 04:32 PM
  7. Replies: 2
    Last Post: 06-22-2010, 07:55 AM

Tags for this Thread

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