View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 718
Default Check for an item in a collection (without looping)

Let's say I have sheets 1 to 10, and I add some of those sheets to a
collection. I want to be able to test whether a given sheet (say sheet8) is
a member of that collection. I know I could test each item in the collection
using a loop, but I want to avoid that if posible. Any help??

set SheetsCollection = sheets(Array("Sheet1", "Sheet7", "Sheet4"))

For each sht in Activeworkbook.sheets
' If sht is in SheetsCollection then
msgbox "Sheet found in collection"
' else
msgbox "Sheet not Found in collection"
' end if
Next