Tom Ogilvy

H

halem2

Hi Tom:

a few pages back you helped me with this macro to clean several sheet
by calling a macro called ClearSheet.

Sub CleanAllSheets()
For Each sh In ActiveWorkbook.Worksheets
sh.Activate
ClearSheet
Next
End Sub

I have a sheet in the workbook that is protected and the macro fail
when it gets to it. How can I run it on all sheets except on a shee
called FORM?

thanks a million..
 
G

Guest

Try this...

Sub CleanAllSheets()
For Each sh In ActiveWorkbook.Worksheets
if sh.name <> "FORM" then
sh.Activate
ClearSheet
End if
Next
End Sub
 
T

Tom Ogilvy

I would suggest a slight revision to make it case insensitive

Sub CleanAllSheets()
Dim sh as Worksheet
For Each sh In ActiveWorkbook.Worksheets
if Ucase(sh.name) <> "FORM" then
sh.Activate
ClearSheet
End if
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top