Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to open, calculate, the save many files.

I would like to open, calculate, then close about 200 plus files. The files
are too large to open at once. I need to open one file, calculate, then
close it before opening the next file. The file names are in column A, the
path is the same for all files. I am guessing this involves an "array".
Unfortunately I haven't yet learned to work with arrays. Hope somebody can
help me. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Macro to open, calculate, the save many files.

Something like

Dim aryNames
Dim i As Long

aryNames = Array("File1.xls", "File2.xls", "File3.xls", _
"File4.xls")
For i = LBound(aryNames) To UBound(aryNames)
Workbooks.Open aryNames(i)
'your code
ActiveWorkbook.Close savechanges:=False
Next i


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"msdrolf" wrote in message
...
I would like to open, calculate, then close about 200 plus files. The

files
are too large to open at once. I need to open one file, calculate, then
close it before opening the next file. The file names are in column A,

the
path is the same for all files. I am guessing this involves an "array".
Unfortunately I haven't yet learned to work with arrays. Hope somebody

can
help me. Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Macro to open, calculate, the save many files.

Hi M,

Subject to your requirements, you may be able to interrogate the files
without opening them.

For pointers, see Ron de Bruin's example code at:

http://www.rondebruin.nl/ado.htm

and

http://www.rondebruin.nl/copy7.htm



---
Regards,
Norman


"msdrolf" wrote in message
...
I would like to open, calculate, then close about 200 plus files. The
files
are too large to open at once. I need to open one file, calculate, then
close it before opening the next file. The file names are in column A,
the
path is the same for all files. I am guessing this involves an "array".
Unfortunately I haven't yet learned to work with arrays. Hope somebody
can
help me. Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro to open, calculate, the save many files.

Oops,

Savechanges should be true, not false.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Bob Phillips" wrote in message
...
Something like

Dim aryNames
Dim i As Long

aryNames = Array("File1.xls", "File2.xls", "File3.xls", _
"File4.xls")
For i = LBound(aryNames) To UBound(aryNames)
Workbooks.Open aryNames(i)
'your code
ActiveWorkbook.Close savechanges:=False
Next i


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"msdrolf" wrote in message
...
I would like to open, calculate, then close about 200 plus files. The

files
are too large to open at once. I need to open one file, calculate, then
close it before opening the next file. The file names are in column A,

the
path is the same for all files. I am guessing this involves an "array".
Unfortunately I haven't yet learned to work with arrays. Hope somebody

can
help me. Thanks.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Macro to open, calculate, the save many files.

Thanks for the input. One follow-up question:
Is it necessary to list all files in the Array("File1.xls",....) or is it
possible to somehow input a range with all the file names - there are over
200 files.

"Bob Phillips" wrote:

Something like

Dim aryNames
Dim i As Long

aryNames = Array("File1.xls", "File2.xls", "File3.xls", _
"File4.xls")
For i = LBound(aryNames) To UBound(aryNames)
Workbooks.Open aryNames(i)
'your code
ActiveWorkbook.Close savechanges:=False
Next i


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"msdrolf" wrote in message
...
I would like to open, calculate, then close about 200 plus files. The

files
are too large to open at once. I need to open one file, calculate, then
close it before opening the next file. The file names are in column A,

the
path is the same for all files. I am guessing this involves an "array".
Unfortunately I haven't yet learned to work with arrays. Hope somebody

can
help me. Thanks.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to open, calculate, the save many files.

You can pick up the values from a range in the worksheet like:

Option Explicit
Sub testme01()
Dim aryNames As Variant
Dim i As Long

With Worksheets("sheet1")
aryNames = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp)).Value
End With

For i = LBound(aryNames, 1) To UBound(aryNames, 1)
MsgBox aryNames(i, 1)
'Workbooks.Open aryNames(i, 1)
'your code
'ActiveWorkbook.Close savechanges:=True 'or false
Next i

End Sub

This assumes that the names are all in column A starting with A1.

That aryNames is a 2 dimensional array (200 rows by 1 column). That's why
there's that ", 1" hanging around. It means the first (and only) column.

msdrolf wrote:

Thanks for the input. One follow-up question:
Is it necessary to list all files in the Array("File1.xls",....) or is it
possible to somehow input a range with all the file names - there are over
200 files.

"Bob Phillips" wrote:

Something like

Dim aryNames
Dim i As Long

aryNames = Array("File1.xls", "File2.xls", "File3.xls", _
"File4.xls")
For i = LBound(aryNames) To UBound(aryNames)
Workbooks.Open aryNames(i)
'your code
ActiveWorkbook.Close savechanges:=False
Next i


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"msdrolf" wrote in message
...
I would like to open, calculate, then close about 200 plus files. The

files
are too large to open at once. I need to open one file, calculate, then
close it before opening the next file. The file names are in column A,

the
path is the same for all files. I am guessing this involves an "array".
Unfortunately I haven't yet learned to work with arrays. Hope somebody

can
help me. Thanks.





--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Macro (open and save files with different drives) jxbeeman Excel Discussion (Misc queries) 1 September 25th 09 07:40 PM
How can I save all open excel files? Cobaum Excel Discussion (Misc queries) 3 September 1st 09 11:02 PM
Fix for open/save files problem Patricia Shannon Excel Discussion (Misc queries) 0 April 25th 06 03:46 PM
Macro to open *.dat files and save as .txt (comma delimited text files) [email protected] Excel Programming 2 November 30th 05 05:50 AM
Open Save & Close All Files in Dir Diane Alsing Excel Programming 5 January 31st 05 07:47 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"