This example will copy the range "a1:c5" from the first worksheet in the workbook where the code
is in to the first sheet in the same range of all workbooks in the folder c:\Data.
You can change the range and the sheet name as you like.
There is a macro that does a normal copy and one that is only copy the values.
Sub TestFile()
Dim basebook As Workbook
Dim mybook As Workbook
Dim sourceRange As Range
Dim destrange As Range
Dim i As Long
Application.ScreenUpdating = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\Data"
.SearchSubFolders = False
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
Set basebook = ThisWorkbook
For i = 1 To .FoundFiles.Count
Set mybook = Workbooks.Open(.FoundFiles(i))
Set sourceRange = basebook.Worksheets(1).Range("a1:c5")
Set destrange = mybook.Worksheets(1).Range("a1")
sourceRange.Copy destrange
mybook.Close True
Next i
End If
End With
Application.ScreenUpdating = True
End Sub
Terms
and Conditions of use
The applications/code on this site are distributed as is and without warranties
or liability. In no event shall the owner of the copyrights, or the authors
of the applications/code be liable for any loss of profit, any problems
or any damage resulting from the use or evaluation of the applications/code.