ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Very simple (https://www.excelbanter.com/excel-programming/295324-very-simple.html)

Aaron Cooper

Very simple
 


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!

Chip Pearson

Very simple
 
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





"Aaron Cooper" wrote in message
...


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!




TH[_3_]

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

On 4/16/04 10:57, in article , "Aaron
Cooper" wrote:



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!




All times are GMT +1. The time now is 03:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com