Say you have three files you'd like to keep open. You could, as you suggest, store their names in an array:
dim WBkeep(3) as string
dim wb as workbook
dim i as integer
dim CloseIt as boolean
WBkeep(1)="Keep this one.xls"
WBkeep(2)="And this one.xls"
WBkeep(3)="And another one.xls"
now, when you go to close the workbooks:
for each wb in workbooks
CloseIt=true
for i=1 to 3
CloseIt=CloseIt and (wb.name<>wbkeep(i))
next i
if CloseIt then wb.close
next wb
That's just one way to do it. You could also use a select case statement, such as:
for each wb in workbooks
select case wb.name
case "Keep this one.xls":
case "And this one.xls":
case "And another one.xls":
case else
wb.close
end selct
next wb
(you can only use this approach if you know the ones to keep ahead of time)
next wb
Rob
![[flowerface] [flowerface] [flowerface]](/data/assets/smilies/flowerface.gif)