Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Excluding sheet in loop

I am trying to get a loop that will go to all sheets in a
book and clear certain cells. There are 2 sheets that I
don't want to delete anything on. The names of these
sheets don't change, but the rest of the sheets do. My
loop works to delete the cells off of all of the sheets,
but I want to exclude these two sheets. How do I exclude 2
sheets from that loop?

Thanks,
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excluding sheet in loop

Piece of cake:

Activeworkbook.Sheets(1).Select
For X = 1 to Activeworkbook.Sheets.Count
If Sheets(X).Name = "whatever" or Sheets(X).Name
= "Whatever else" then
X = X + 1
Else
do your thing
End If
Sheets(X).Select
Next X
-----Original Message-----
I am trying to get a loop that will go to all sheets in

a
book and clear certain cells. There are 2 sheets that I
don't want to delete anything on. The names of these
sheets don't change, but the rest of the sheets do. My
loop works to delete the cells off of all of the sheets,
but I want to exclude these two sheets. How do I exclude

2
sheets from that loop?

Thanks,
David
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Excluding sheet in loop

Dim sh as worksheet
for each sh in thisworkbook.Worksheets
if not (sh.Name = "Sheet1" or sh.Name = "Sheet2") then
'process the sh
sh.Range("A1").ClearContents 'as an example
end if
Next

Regards,
Tom Ogilvy
david wrote in message
...
I am trying to get a loop that will go to all sheets in a
book and clear certain cells. There are 2 sheets that I
don't want to delete anything on. The names of these
sheets don't change, but the rest of the sheets do. My
loop works to delete the cells off of all of the sheets,
but I want to exclude these two sheets. How do I exclude 2
sheets from that loop?

Thanks,
David



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Christina Excel Discussion (Misc queries) 0 March 17th 10 08:55 PM
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
How to loop saman110 via OfficeKB.com Excel Discussion (Misc queries) 4 July 25th 07 01:09 AM
How would I add a loop for this? [email protected] Excel Discussion (Misc queries) 3 September 18th 06 01:21 PM
paste excel sheet excluding hidden rows Bernie Excel Discussion (Misc queries) 3 March 5th 06 02:17 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"