View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Fred[_17_] Fred[_17_] is offline
external usenet poster
 
Posts: 20
Default Link all values in a workbook under same folder on one sheet

Hi !

You can try the following code to:
- loop through a folder
- Open all .xls files
- Loop through the sheets
- Save and close the workbook



Sub LoopFolder()

Dim FileName As String
Dim FindDirectory As String

FindDirectory = "C:\Temp\" 'Put your foldername here

FileName = Dir(FindDirectory, vbNormal)
Do While FileName < ""
If Right(FileName, 4) = ".xls" Then
Workbooks.Open FileName:=FindDirectory & FileName
'Do whatever you have to do withe the workbook, for example:
For Each sh In ActiveWorkbook.Sheets
Debug.Print FileName & " - " & sh.Name
Next sh
ActiveWorkbook.Close savechanges:=True
End If
FileName = Dir
Loop

End Sub


"m" wrote in message
...
Hi there!

Am doing a consolidation macro that will require me to
sum all values in a specific cell (e.g. A1), under same
worksheet (e.g Sheet1) of all the workbooks (of
indefinite number) found under one folder.

Can anyone provide me a sample script can use? Tnx a
bunch! =)