Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Ru;n a Routine on all Sheets Except 2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Izran - 25 Jan 2006 19:13 GMT
Here is the situation.  I am writing a routine to generater output
reports.  I have a sheet with a template of the page setup and another
sheet that I am going to transfer that into.  The users can import
multiple sheets of data.  This routine needs to go through their sheets
to extrapolate the necessary information.  So I need my routine to go
through every sheet except the template sheet and and output report
sheet.  I guess I can set a flag up on those two sheets such that if it
reads the flag it goes onto the next sheet, but I wonder if there is a
better way.

Mike
Jim Thomlinson - 25 Jan 2006 19:35 GMT
The only trick is you need to be able to identify the sheets, no matter what.
Something like this should work for you...

dim wks as worksheet

for each wks in worksheets
 select case wks.codename
   case "Sheet1"
   case "Sheet2"
   case else
      'Run your routine on wks
 end select
next wks

Make sure you use the code name for the sheet as opposed to the name (Tab
name) which could be changed by the user. Code name is the one you see in the
VB Explorer  Sheet1(TabName)...
Signature

HTH...

Jim Thomlinson

> Here is the situation.  I am writing a routine to generater output
> reports.  I have a sheet with a template of the page setup and another
[quoted text clipped - 7 lines]
>
> Mike
Sprinks - 25 Jan 2006 19:35 GMT
Thanks, Jim.  I was not aware of that property.

Sprinks

> The only trick is you need to be able to identify the sheets, no matter what.
> Something like this should work for you...
[quoted text clipped - 25 lines]
> >
> > Mike
Izran - 25 Jan 2006 19:41 GMT
Thank you very much.  It's always the simple things that can trip you
up.......

Regards,
MPManzi
Sprinks - 25 Jan 2006 19:35 GMT
If the two sheets to exclude are named consistently, you can use that property:

Dim wrksht As Worksheet
For Each wrksht In ActiveWorkbook.Worksheets
      If (wrksht.Name <> "Templates" AND wrksht.Name<>"OutputReport") Then
              ' Do Stuff here
      End If
Next wrksht

Sprinks

> Here is the situation.  I am writing a routine to generater output
> reports.  I have a sheet with a template of the page setup and another
[quoted text clipped - 7 lines]
>
> Mike
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.