ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tom Ogilvy (https://www.excelbanter.com/excel-programming/310222-tom-ogilvy.html)

halem2[_26_]

Tom Ogilvy
 
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..

--
Message posted from http://www.ExcelForum.com


Jim Thomlinson[_3_]

Tom Ogilvy
 
Try this...

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


"halem2 " wrote:

Hi Tom:

a few pages back you helped me with this macro to clean several sheets
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 fails
when it gets to it. How can I run it on all sheets except on a sheet
called FORM?

thanks a million...


---
Message posted from http://www.ExcelForum.com/



Tom Ogilvy

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

--
Regards,
Tom Ogilvy


"Jim Thomlinson" wrote in message
...
Try this...

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


"halem2 " wrote:

Hi Tom:

a few pages back you helped me with this macro to clean several sheets
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 fails
when it gets to it. How can I run it on all sheets except on a sheet
called FORM?

thanks a million...


---
Message posted from http://www.ExcelForum.com/





halem2[_27_]

Tom Ogilvy
 
thank you both. Thanks you Tom for all the help

--
Message posted from http://www.ExcelForum.com


halem2[_28_]

Tom Ogilvy
 
thank you both. Thanks you Tom for all the help

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com