View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
mike mike is offline
external usenet poster
 
Posts: 216
Default macro too fast???

I have used a macro for months with no problems.
Yesterday, the macro started erroring out on the specified
line below. The code below is only part of the macro.

I believe the reason it is erroring out is this sheet does
not exist when it hits this line of code. I have looked
at the workbook and the sheet is missing. There is
nothing in the previous code to delete the sheet.

There are currently 3 sheets in the workbook. The 3rd
sheets is temporary and the line below is deleting it
because it is no longer needed.

When I step through the program, I do not get the debug
error on this line. When I run it as normal. I get the
error. Any suggestions to prevent this error would be
greatly appreciated.


Sub ReStart2()

Range("A1").Select

With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With

ActiveWorkbook.PrecisionAsDisplayed = False

Application.ScreenUpdating = False

Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= False, Transpose:=False

Application.DisplayAlerts = False
Worksheets(3).Delete ' errors out here
Application.DisplayAlerts = True

End Sub