Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel XP, WinXP
I have a number of Excel files open, say One.xls, Two.xls, Three.xls. I want to do something with each file in turn in a For loop. The "Test1" macro has a "Type Mismatch" error in the "For" line. What is the correct way to write this "For" line? I finally went with the Test2 macro but it seems awkward. Thanks for your help. Otto Sub Test1() Dim wb As Workbook For Each wb In Workbooks(Array("One.xls", "Two.xls", "Three.xls")) MsgBox wb.Name Next wb End Sub Sub Test2() Dim wb As Workbook Dim wbName As Variant For Each wbName In Array("One.xls", "Two.xls", "Three.xls") MsgBox Workbooks(wbName).Name Next wbName End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
array not working | Excel Discussion (Misc queries) | |||
AVERAGE IF in array not working | Excel Worksheet Functions | |||
3d array not working | Excel Worksheet Functions | |||
Working with an array | Excel Programming | |||
Sum not working on Array | Excel Programming |