473,508 Members | 2,212 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
Expand|Select|Wrap|Line Numbers
  1. Sub datesexcelvba()
  2.  
  3.  
  4. Dim mydate1 As Date
  5. Dim mydate2 As Long
  6. Dim datetoday1 As Date
  7. Dim datetoday2 As Long
  8.  
  9. Dim x As Long
  10. lastrow = Sheets("inspection & test plans").Cells(Rows.Count, 1).End(xlUp).Row
  11. For x = 5 To lastrow
  12.  
  13. mydate1 = Sheets("inspection & test plans").Cells(x, 15).Value
  14. mydate2 = mydate1
  15. Cells(x, 20).Value = mydate2
  16. datetoday1 = Date
  17. datetoday2 = datetoday1
  18. Cells(x, 21).Value = datetoday2
  19.  
  20. If mydate2 - datetoday2 = 14 Then
  21.  
  22. Set myApp = New Outlook.Application
  23. Set mymail = myApp.createitem(olmailitem)
  24. mymail.to = Cells(x, 17).Value
  25. With mymail
  26. .Subject = "payment Reminder"
  27. .body = "your cert expires in 14 days"
  28. '.Send
  29.  
  30. Cells(x, 16) = "Yes"
  31. Cells(x, 16).Interior.ColorIndex = 3
  32. Cells(x, 16).Font.ColorIndex = 2
  33. Cells(x, 19).Value = mydate2 - datetoday2
  34.  
  35. End If
  36.  
  37. Next
  38.  
  39. Set myApp = Nothing
  40. Setmymail = Nothing
  41. End Sub
May 15 '15 #1
1 2306
Rabbit
12,516 Recognized Expert Moderator MVP
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.
May 15 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3787
by: Brice Prunier | last post by:
Here under 4 schemas i'm working with ( it may be long: sorry...) The context is the following : Resident.xsd imports Person.xsd and includes Common.xsd ( anonimous schema: no TargetNamespace )...
2
23913
by: bradleyp | last post by:
Hi all, Hopefully somebody can help. In Access 2002-SP2, I receive an error from the VB Editor if I try to compile the following code (see below). The error is as follows: Compile Error:...
10
19690
by: Chris LaJoie | last post by:
Our company has been developing a program in C# for some time now, and we haven't had any problems with it, but just last night something cropped up that has me, and everyone else, stumped. I...
0
1879
by: Jim Heavey | last post by:
Internal Compiler Error: stage 'BEGIN' Hello, I had an application which was working just fine and I decided to modify all database access within the application to utilizie a new Namespace that I...
1
5142
by: kieran04 | last post by:
every time i run this program in VBE i keep getting the message 'Compile Error: expected array' for the two bold lines underneath, please help? Public Function KnotsToKmPerHr(knots As...
7
3484
by: Arjuna | last post by:
I have a class template (ExclusiveMap) which takes two type parameters C1 and C2 and declares two private members map<C1, C2> and map<C2, C1> (both STL maps). In test code I instantiate this class...
3
3493
by: winson oo | last post by:
I don't know why it pop up this error when I want to compile the program. ( the problem of the souce code that I'm facing in in the bolder style. Thanks for checking! Private Sub...
1
1476
by: iamahmar | last post by:
Sqlquery = "select * from general_journal_temp_TBL " Set Rs = db.OpenRecordset(Sqlquery1, dbOpenDynaset) If Not Rs.EOF Then Do While Not Rs.EOF Sqlquery1 = "select *...
3
3087
by: Vasago | last post by:
I am getting a this compile error on line 22 and I do have the Select case and End Select. Select Case Case 1 DoCmd.OpenReport "Charter Order Form", wherecondition:="Bookings.ID='" &...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7501
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3204
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.