Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Interuption with no explaination :/
Hi. I've had this error a couple of times, and can't figure it out.
I write a macro and when running it I get "Code Execution has been interupted" and when I debug it's on random lines... Today i've wrote a macro, which I'll attach at the bottom. The macro worked great, but since I don't need to watch it running and it'd be quicker I turned screen updating off. Now it errors. The error comes up mostly on "If n = 0 Then" and looking at it n = 1 at that point, but half the time it will be a random line of code that seemingly looks fine to me... dat is yesterday's date from the workbook, so it deletes all lines with previous date, and if column 4 is Z then its not an appointment and wants deleting. day1 and day2 are files with a name based on today's date, so are variable. As far as I can tell theres nothing wrong with this code. I certainly get none of the normal errors when I write something shoddy, just the interuption thing... i'm not pressing any keys or anything while it runs it just seems to interupt itself for no reason I can see... Sub open_reports() Dim day1 As Variant Dim day2 As Variant Dim i As Variant Dim dat As Variant Dim n As Variant Application.ScreenUpdating = False Sheets("Calc").Select day1 = Range("B19").Value day2 = Range("C19").Value dat = Range("F2").Value Workbooks.Open Filename:= _ day1 Sheets("diary").Select Windows("Appointments Booked.xls").Activate Workbooks.Open Filename:= _ day2 Sheets("diary").Select Cells.Select Selection.Copy Windows("Appointments Booked.xls").Activate Sheets("Sheet3").Select Range("A1").Select ActiveSheet.Paste Windows("Appointments Booked.xls").Activate Range("B2").Select i = 2 Do Until i = 50000 n = 0 If Cells(i, 4) = "Z" Then n = 1 Else End If If Cells(i, 5) < dat Then n = 1 Else End If If n = 1 Then Rows(i).Delete If n = 0 Then i = i + 1 Loop End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Function explaination need | Excel Worksheet Functions | |||
Formula explaination | Excel Discussion (Misc queries) | |||
Need some help and explaination. Thks. | Excel Programming | |||
Need some help and explaination. Thks. | Excel Programming | |||
Need some help and explaination. Thks. | Excel Programming |