View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
macgru macgru is offline
external usenet poster
 
Posts: 20
Default Opening Files Using VBA


Uzytkownik napisal w wiadomosci
ups.com...
I have a named range (FilesToOpen) that contains a variable number of
filenames and path (i.e. c:\mydoc\text.xls) that need to be opened
(range FileCount contains number of files).

What I want to do is have a macro that opens all the files in
FilesToOpen range, calculates the original sheet, and then close the
files opened by the macro.

I've been trying with For and Next and open file Range etc. but am
strugling with the syntax. Any help appreciated. Thanks.


Sub test()
Dim filename As String
For Each cell In Range("a1:a2")
filename= "c:\" & cell.Value & ".xls"
Workbooks.Open Filename:=filename
.....
...


Next filename
End Sub

hope this help
mcg