I need to open 12 different workbooks copy the data to 1 workbook in 12 sheets and make each range a table, any way to make the code faster than what I wrote? all workbooks are in one shared folder, mixed with different workbooks that do not need to be opened. The current run time is 20 seconds
Sub callstuff()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Call CurrentRegionArray("helper1", "book2.xlsx", "sheet2", "J4")
Call CurrentRegionArray("helper2", "book3.xlsx", "sheet3", "J4")
Call CurrentRegionArray("helper3", "book4.xlsx", "sheet4", "J4")
Call CurrentRegionArray("helper4", "book5.xlsx", "sheet5", "J4")
Call CurrentRegionArray("helper5", "book6.xlsx", "sheet6", "J4")
Call CurrentRegionArray("helper6", "book7.xlsx", "sheet7", "J4")
Call CurrentRegionArray("helper7", "book8.xlsx", "sheet8", "J4")
Call CurrentRegionArray("helper8", "book9.xlsx", "sheet9", "J4")
Call CurrentRegionArray("helper9", "book10.xlsx", "sheet10", "J4")
Call CurrentRegionArray("helper10", "book11.xlsx", "sheet11", "J4")
Call CurrentRegionArray("helper11", "book12.xlsx", "sheet12", "J4")
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Sub CurrentRegionArray(TableName As String, WorkBookName As String, SheetName As String, RangeName As String)
Dim strPath As String
strPath = "/Users/dimagoroh/Desktop/nastia stuff "
Application.Workbooks.Open (strPath & "/" & WorkBookName)
'copy range to array and copy that array to diffrent sheet
With Workbooks("book1.xlsm").Worksheets(SheetName).Range(RangeName)
oarray = Workbooks(WorkBookName).Worksheets("sheet1").ListObjects("leavetracker").DataBodyRange.Value
.CurrentRegion.Clear
.Resize(UBound(oarray, 1), UBound(oarray, 2)) = oarray
End With
'Seting range as table and giving it a name
Dim rngTable As Range
With Workbooks("book1.xlsm").Worksheets(SheetName)
Set rngTable = .Range(RangeName).CurrentRegion
.ListObjects.Add(xlSrcRange, rngTable, , xlYes).Name = TableName
End With
Workbooks(WorkBookName).Close
Erase oarray
End Sub