Very simple

A

Aaron Cooper

This has got to be one of the easiest questions ever asked. I'm trying
to add a loop ( a For each loop) to a macro that will perform the macro
on all but one worksheet in the current workbook. The only worksheet
that I do not what it to run on will always have the same name, but the
sheets that I want the macro to run on will not always be the same.

Can anyone help?

Thanks.

Aaron

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
C

Chip Pearson

Aaron,

Try some code like the following:

Dim WS As Worksheet
For Each WS In ThisWorkbook.Worksheets
If StrComp(WS.Name, "do_not_process") <> 0 Then
' do something with WS
End If
Next WS

This will do something with every worksheet except the one named
"do_not_process".


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
T

TH

For i = 1 to sheets.count
if worksheets(i).name <> "YourSheetNameToExclude" then
'run your macro...which must refer to worksheets(i)
end if
next
 
Top