I suspect this could be your problem
If mySheet.Range("C2") = "Empty" Then
Maybe assuming you have a set mystoragebook=something
For Each ws In myStorageBook.Worksheets
If ws.Name <> "Input" And ws.Name <> "Summary then
Application.DisplayAlerts = False
ws.Delete
Application.DisplayAlerts = True
else ws.columns("D:G").AutoFit
end if
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"WhytheQ" <(E-Mail Removed)> wrote in message
news:a2bf0778-6c01-4c0b-8648-(E-Mail Removed)...
>I suspect that the following bit of code is causing problems - not
> causing an arror - just stopping the macro part way through without an
> error. Does anyone know any other ways of coding the follow, I suspect
> it is the for Each loop causing the problems:
>
> Any help appreciated
> Jason
>
> '====================================
> For Each mySheet In myStorageBook.Worksheets
>
> 'check to see if the storage sheet is being used
> 'if it isn't then delete it
> If mySheet.Range("C2") = "Empty" Then
> Application.DisplayAlerts = False
> mySheet.Delete
> Application.DisplayAlerts = True
> Else
> If mySheet.Name <> "Input" And mySheet.Name <> "Summary"
> Then
> mySheet.Range("D:G").EntireColumn.AutoFit
> End If
> End If
> Next
> '====================================