Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default How to increment within For Next Loop

2003

With in the following loop:

For Each wks In Worksheets
(I am trying to increment to "Next" wks in Worksheets if
any sheets listed in the array occur)
If wks.name = Array("Do not process1","Do not process2", _
"Do not process3") Then _
Next wks

Next wks

I do not think that I can wks = wks +1 as wks is not numeric

Also, I may not be handling the array properly.

How can I have the For ... Next loop skip all worksheets named as
in the array?


Thanks EagleOne

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to increment within For Next Loop

dim wks as worksheet

for each wks in activeworkbook.worksheets
select case lcase(wks.name)
case is = "sheet1", "sheet3", "sheet9", "sheet11"
'do nothing
case else
'do your work here
end select
next wks

=====
or...

dim wksNamesToAvoid as Variant
dim wks as worksheet

wksnamestoavoid = array("sheet1", "sheet3", "sheet9", "sheet11")

for each wks in activeworkbook.worksheets
if isnumeric(application.match(wks.name,wksnamestoavo id,0)) then
'do nothing
else
'do your work here
end if
next wks

You don't want to change the worksheet in your loop--just don't do anything if
that name matches your list.

EagleOne wrote:

2003

With in the following loop:

For Each wks In Worksheets
(I am trying to increment to "Next" wks in Worksheets if
any sheets listed in the array occur)
If wks.name = Array("Do not process1","Do not process2", _
"Do not process3") Then _
Next wks

Next wks

I do not think that I can wks = wks +1 as wks is not numeric

Also, I may not be handling the array properly.

How can I have the For ... Next loop skip all worksheets named as
in the array?

Thanks EagleOne


--

Dave Peterson
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
'Scroll bar' - to increment btwn MIN and MAX value. jay Charts and Charting in Excel 1 April 28th 06 02:15 AM
Loop time seems dependent on unrelated workbook - Why? Richard Excel Worksheet Functions 2 March 30th 06 11:59 PM
Loop gone crazy Dave Peterson Excel Discussion (Misc queries) 4 December 16th 05 03:38 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
Relative reference autofill increment other than +1 SteveB Excel Discussion (Misc queries) 3 June 14th 05 07:40 PM


All times are GMT +1. The time now is 07:23 PM.

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

About Us

"It's about Microsoft Excel"