Closed Thread
Results 1 to 2 of 2

Block If without End If

  1. #1
    Registered User
    Join Date
    10-12-2010
    Location
    United States
    MS-Off Ver
    Excel 2007
    Posts
    3

    Unhappy Block If without End If

    When I try to run the following VBA code, I get a Block If without End If error. I can't figure out where I need to add the missing End If or if there is more than one End If needed.

    Public Sub Send_Email()
    'If Check_Questions = True Then
    Dim myOlApp As New Outlook.Application
    Dim myItem As Outlook.MailItem
    Dim myAttachments As Outlook.Attachments
    Dim strfile, strfile2, rename As String
    Dim i, m, l, j As Integer

    Dim dir As String

    dir = BrowseForFolder

    Worksheets("Answers").Range("A1:P1000").Delete

    If Worksheets("Directions").Range("C23") = "Air Force" Then

    AFDemo

    ' gather answers

    If Worksheets("Directions").Range("C25") = "Fixed Wing" Then
    If Worksheets("Directions").Range("C-27") = "Post Event" Then
    AFFWPE
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Fixed Wing" Then
    If Worksheets("Directions").Range("C27") = "Post Test" Then
    AFFWPT
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Rotary Wing" Then
    If Worksheets("Directions").Range("C-27") = "Post Event" Then
    AFRWPE
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Rotary Wing" Then
    If Worksheets("Directions").Range("C27") = "Post Test" Then
    AFRWPT
    End If

    Else

    If Worksheets("Directions").Range("C27") = "Technician" Then
    AFTech
    End If

    If Worksheets("Directions").Range("C23") = "Navy" Then

    NDemo

    If Worksheets("Directions").Range("C25") = "Fixed Wing" Then
    If Worksheets("Directions").Range("C-27") = "Post Event" Then
    NFWPE
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Fixed Wing" Then
    If Worksheets("Directions").Range("C27") = "Post Test" Then
    NFWPT
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Rotary Wing" Then
    If Worksheets("Directions").Range("C-27") = "Post Event" Then
    NRWPE
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Rotary Wing" Then
    If Worksheets("Directions").Range("C27") = "Post Test" Then
    NRWPT
    End If

    Else

    If Worksheets("Directions").Range("C27") = "Technician" Then
    NTech
    End If


    If Worksheets("Directions").Range("C23") = "Army" Then

    ADemo

    If Worksheets("Directions").Range("C25") = "Fixed Wing" Then
    If Worksheets("Directions").Range("C-27") = "Post Event" Then
    AFWPE
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Fixed Wing" Then
    If Worksheets("Directions").Range("C27") = "Post Test" Then
    AFWPT
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Rotary Wing" Then
    If Worksheets("Directions").Range("C-27") = "Post Event" Then
    ARWPE
    End If

    Else

    If Worksheets("Directions").Range("C25") = "Rotary Wing" Then
    If Worksheets("Directions").Range("C27") = "Post Test" Then
    ARWPT
    End If

    Else

    If Worksheets("Directions").Range("C27") = "Technician" Then
    ATech
    End If


    End If

    End If

    End If

    If Worksheets("Directions").Range("C23") = "Air Force" Then

    strfile = dir & "\Air Force , " & Worksheets("Directions").Range("C25") & " , " & Worksheets("Directions").Range("C27") & " , " & Worksheets("PI AF").Range("D8") & " , " & _
    Worksheets("PI AF").Range("D10") & " , " & Worksheets("Directions").Range("E23") & "-" & _
    Worksheets("Directions").Range("F23") & "-" & Worksheets("Directions").Range("G23") & " JSAM Questionnaire.xlsm"

    strfile2 = dir & "\Air Force , " & Worksheets("Directions").Range("C25") & " , " & Worksheets("Directions").Range("C27") & " , " & Worksheets("PI AF").Range("D8") & " , " & _
    Worksheets("PI AF").Range("D10") & " , " & Worksheets("Directions").Range("E23") & "-" & _
    Worksheets("Directions").Range("F23") & "-" & Worksheets("Directions").Range("G23") & " JSAM Answers.csv"


    Else

    strfile = dir & "\" & Worksheets("Directions").Range("C23") & " , " & Worksheets("Directions").Range("C25") & " , " & Worksheets("Directions").Range("C27") & " , " & _
    Worksheets("PI A-N").Range("D8") & " , " & Worksheets("PI A-N").Range("D10") & " , " & _
    Worksheets("Directions").Range("E23") & "-" & Worksheets("Directions").Range("F23") & "-" _
    & Worksheets("Directions").Range("G23") & " JSAM Questionnaire.xlsm"

    strfile2 = dir & "\" & Worksheets("Directions").Range("C23") & " , " & Worksheets("Directions").Range("C25") & " , " & Worksheets("Directions").Range("C27") & " , " & _
    Worksheets("PI A-N").Range("D8") & " , " & Worksheets("PI A-N").Range("D10") & " , " & _
    Worksheets("Directions").Range("E23") & "-" & Worksheets("Directions").Range("F23") & "-" _
    & Worksheets("Directions").Range("G23") & " JSAM Answers.csv"


    End If

    MsgBox "An Outlook email will appear once you click ok. Please click send on that email and you are done!" & _
    " Thank you for filling out the JSAM Electronic Questionnaire.", vbInformation, "Hint"


    ActiveWorkbook.Worksheets("Answers").SaveAs Filename:=strfile2, FileFormat:=xlCSV, CreateBackup:=False


    ActiveWorkbook.SaveAs Filename:=strfile, FileFormat:= _
    xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False


    Set myItem = myOlApp.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    myAttachments.Add strfile, olByValue, 1, "Test"
    myAttachments.Add strfile2, olByValue, 1, "Test"
    myItem.Display
    myItem.To = "joseph.jones.ctr@eglin.af.mil"
    myItem.Subject = "Finished JSAM Questionnaire"


    End Sub

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,902

    Re: Block If without End If

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

Closed 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