I have written a VBA code in order to open a number of input files, copy their contents and paste them in other output files on specific sheets.
The code works fine but it is running slow (Around 1h30) Would you be able to provide tips on how to improve this piece of code ?
`For j = 2 To 5
For i = 1 To 10
Workbooks.Open Filename:=Paths_Inputs_Total(i)
Range("A1").CurrentRegion.Copy
Workbooks.Open Filename:=Output_Paths(j)
If InStr(1, Output_Tabs_Total(i), "AP") <> 0 Then
Sheets(Output_Tabs_Total(i)²).Range("A:BA").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ElseIf InStr(1, Output_Tabs_Total(i), "Info MP") <> 0 Then
Sheets(Output_Tabs_Total(i)).Range("D:BF").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Else
Sheets(Output_Tabs_Total(i)).Range("C:BG").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
Application.CutCopyMode = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Next i
Next j`
Thank you in advance !
New contributor
Yazil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.