ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   For Each Sheet But not all (https://www.excelbanter.com/excel-discussion-misc-queries/209318-each-sheet-but-not-all.html)

jlclyde

For Each Sheet But not all
 
Is there a way to do the For Each sheet and exclude sheets to have it
done to at the same time?

Thanks,
Jay

Dave Peterson

For Each Sheet But not all
 
dim wks as worksheet
for each wks in activeworkbook.worksheets
select case lcase(wks.name)
case is = "not this one", "or this one", "and not this"
'do nothing
case else
'do the real work
msgbox wks.name
end select
next wks

Make sure you type the names of the worksheets in lower case.

jlclyde wrote:

Is there a way to do the For Each sheet and exclude sheets to have it
done to at the same time?

Thanks,
Jay


--

Dave Peterson

Sheeloo[_3_]

For Each Sheet But not all
 
for each ws in worksheets
if ws.name<"name you want to exclude" then
'do what you want to do
end if
next

"jlclyde" wrote:

Is there a way to do the For Each sheet and exclude sheets to have it
done to at the same time?

Thanks,
Jay


jlclyde

For Each Sheet But not all
 
On Nov 6, 1:34*pm, Dave Peterson wrote:
dim wks as worksheet
for each wks in activeworkbook.worksheets
* *select case lcase(wks.name)
* * * *case is = "not this one", "or this one", "and not this"
* * * * * 'do nothing
* * * *case else
* * * * * 'do the real work
* * * * * msgbox wks.name
* *end select
next wks

Make sure you type the names of the worksheets in lower case.

jlclyde wrote:

Is there a way to do the For Each sheet and exclude sheets to have it
done to at the same time?


Thanks,
Jay


--

Dave Peterson


Dave,
You have been saving my butt left and right. Thanks again.
Jay

joel

For Each Sheet But not all
 
Sub test()

exclude = Array("A", "B", "C")

For Each sht In Sheets
Found = False
For Each itm In exclude
If UCase(sht.Name) = UCase(tim) Then
Found = True
Exit For
End If
If Found = False Then

'enter you code here

End If
Next itm

Next sht


End Sub


"jlclyde" wrote:

Is there a way to do the For Each sheet and exclude sheets to have it
done to at the same time?

Thanks,
Jay



All times are GMT +1. The time now is 12:30 PM.

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