LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function explaination need hoachen Excel Worksheet Functions 2 July 26th 07 11:38 PM
Formula explaination r Excel Discussion (Misc queries) 6 May 16th 06 04:12 AM
Need some help and explaination. Thks. stevetan2010[_3_] Excel Programming 0 November 16th 04 03:58 AM
Need some help and explaination. Thks. stevetan2010[_2_] Excel Programming 1 November 10th 04 12:34 AM
Need some help and explaination. Thks. stevetan2010 Excel Programming 0 November 9th 04 03:09 AM


All times are GMT +1. The time now is 01:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"