![]() |
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 |
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 |
All times are GMT +1. The time now is 09:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com