View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
S. I. Becker S. I. Becker is offline
external usenet poster
 
Posts: 15
Default Deleting a sheet if it exists?

drucey wrote:
Me again!

Flying along nicely, apart from...

In a macro i have:

Sheets("Completed Orders").Delete
Sheets("Partially Arrived Orders").Delete
Sheets("Draft Orders").Delete
Sheets("Placed Orders").Delete

But coming from another macro that's already deleted them (in some
cases only)..

How would i say

IF sheet "completed orders" exists then delete else not to worry

Thanks all


By wrapping the code in an error trapping block, for instance

Sub DeleteIfExists(ByVal SheetName as String)
On Error Resume Next
Sheets(SheetName).Delete
Err.Clear
End Sub