every time I run the programme below, I get Compile Error 'End if without blockif'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bnwalema
    New Member
    • May 2015
    • 1

    #1

    every time I run the programme below, I get Compile Error 'End if without blockif'

    Code:
    Sub datesexcelvba()
    
    
    Dim mydate1 As Date
    Dim mydate2 As Long
    Dim datetoday1 As Date
    Dim datetoday2 As Long
    
    Dim x As Long
    lastrow = Sheets("inspection & test plans").Cells(Rows.Count, 1).End(xlUp).Row
    For x = 5 To lastrow
    
    mydate1 = Sheets("inspection & test plans").Cells(x, 15).Value
    mydate2 = mydate1
    Cells(x, 20).Value = mydate2
    datetoday1 = Date
    datetoday2 = datetoday1
    Cells(x, 21).Value = datetoday2
    
    If mydate2 - datetoday2 = 14 Then
    
    Set myApp = New Outlook.Application
    Set mymail = myApp.createitem(olmailitem)
    mymail.to = Cells(x, 17).Value
    With mymail
    .Subject = "payment Reminder"
    .body = "your cert expires in 14 days"
    '.Send
    
    Cells(x, 16) = "Yes"
    Cells(x, 16).Interior.ColorIndex = 3
    Cells(x, 16).Font.ColorIndex = 2
    Cells(x, 19).Value = mydate2 - datetoday2
    
    End If
    
    Next
    
    Set myApp = Nothing
    Setmymail = Nothing
    End Sub
    Last edited by Rabbit; May 15 '15, 11:45 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code or formatted data. Your thread has been moved to the Excel forum.

    You started a With block and never ended it.

    Comment

    Working...