Hi
My code below loops through 30+ workbooks saved in a server folder, and copy/pastes all data within each into a corresponding worksheet (each workbook has a matching worksheet name). It works but takes a bit of time.
Is there a way to improve the speed in which it executes? For example, avoiding selecting a range, copying and pasting? Any ideas or suggestions please;
My code;
Thanks in advance
My code below loops through 30+ workbooks saved in a server folder, and copy/pastes all data within each into a corresponding worksheet (each workbook has a matching worksheet name). It works but takes a bit of time.
Is there a way to improve the speed in which it executes? For example, avoiding selecting a range, copying and pasting? Any ideas or suggestions please;
My code;
VBA Code:
Dim ws As Worksheet
Dim PathOfWorkbboks
Dim objFolder As Object
Dim objFile As Object
Dim Main
Dim ShtName, objName
Main = "Group reporting.xlsm"
Windows(Main).Activate
PathOfWorkbboks = "[REDACTED]"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(PathOfWorkbboks)
For x = 1 To Sheets.Count
With Sheets(x)
Sheets(x).Activate
ShtName = Mid(Sheets(x).Name, 1) & ".xlsx"
For Each objFile In objFolder.Files
objName = objFSO.Getfilename(objFile.Path)
If objName = ShtName Then
Workbooks.Open objFile
Sheets("sheet1").Select
Cells.Select
Selection.Copy
Windows(Main).Activate
Range("A1:Q50").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Workbooks(objName).Close savechanges:=False
End If
Next
End With
Next x
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.StatusBar = True
Thanks in advance