![]() |
Exclude some worksheets when using UsrSht function
Hello - I am using the following script to set print areas and run a macro fo many worksheets at once. Works great, except that I really need t exclude about 5 worksheets from a 100 sheet workbook when using th function. Any suggestions would be appreciated! Sub SetRange() For Each UsrSht In ActiveWorkbook.Worksheets UsrSht.PageSetup.PrintArea = "$A$1:$F$30" Next UsrSht End Sub thanks, Annabe -- annabe ----------------------------------------------------------------------- annabel's Profile: http://www.excelforum.com/member.php...fo&userid=2652 View this thread: http://www.excelforum.com/showthread.php?threadid=44141 |
Exclude some worksheets when using UsrSht function
Sub SetRange()
Dim UsrSht as Worksheet Dim sName as String For Each UsrSht In ActiveWorkbook.Worksheets sName = lcase(UsrSht.Name) if sName < "sheet1" and sName < "sheet5" and _ sName < "sheet10" and sName < "sheet15" and _ sName < "summary" then UsrSht.PageSetup.PrintArea = "$A$1:$F$30" end if Next UsrSht End Sub make sure the sheet names you check against are lower case as shown. -- Regards, Tom Ogilvy "annabel" wrote in message ... Hello - I am using the following script to set print areas and run a macro for many worksheets at once. Works great, except that I really need to exclude about 5 worksheets from a 100 sheet workbook when using the function. Any suggestions would be appreciated! Sub SetRange() For Each UsrSht In ActiveWorkbook.Worksheets UsrSht.PageSetup.PrintArea = "$A$1:$F$30" Next UsrSht End Sub thanks, Annabel -- annabel ------------------------------------------------------------------------ annabel's Profile: http://www.excelforum.com/member.php...o&userid=26520 View this thread: http://www.excelforum.com/showthread...hreadid=441414 |
Exclude some worksheets when using UsrSht function
Thank you very much - that is exactly what I need!! I appreciate your time and knowledge -- annabe ----------------------------------------------------------------------- annabel's Profile: http://www.excelforum.com/member.php...fo&userid=2652 View this thread: http://www.excelforum.com/showthread.php?threadid=44141 |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com