View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Otto Moehrbach Otto Moehrbach is offline
external usenet poster
 
Posts: 1,090
Default I want a macro that will upload a number of excel files at once.

Greg
That question is above my head. Perhaps someone else will pitch in and
provide you an answer. HTH Otto
"GregR" wrote in message
ups.com...
Otto, how do I modify to include subfolders and only run the macro on
the most recently modified file in the subfolder. TIA

Greg
Otto Moehrbach wrote:
I gather that you want some code to access each file in turn, run your
macro, then close that file and open the next file. Is that right?
The code below will do that if all the files are in the same folder and
you
want to run your macro with each file in that folder. If you want to
exclude some of the files, additional code will be required. Note that
this
macro opens each file in turn. It doesn't make that file the active
file.
If your code is written to operate on only the active file, add the
following line before calling your macro:
Windows(TheFile).Activate
Change the path as necessary.
Please post back and advise us all on how this works or doesn't work for
you. HTH Otto
Sub AllFolderFiles()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\Temp"
ChDir MyPath
TheFile = Dir("*.xls")
Do While TheFile < ""
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
Call YourMacroHere
wb.Close
TheFile = Dir
Loop
End Sub

"Excel Macros" <Excel wrote in message
...
I have a large number of excel files and I want to use a macro to upload
the
data from these files into another excel spreadsheet. The macro that I
currently use requires that I upload these files one at a time. The
number
of
files is so large that this is too time consuming.