Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Loop | Excel Discussion (Misc queries) | |||
Find loop doesn't loop | Excel Discussion (Misc queries) | |||
How to loop | Excel Discussion (Misc queries) | |||
How would I add a loop for this? | Excel Discussion (Misc queries) | |||
paste excel sheet excluding hidden rows | Excel Discussion (Misc queries) |