Hello, can someone help me out here?
This macro works perfectly when I use the file and files being pulled from the C Drive.
But once I moved the file over to the One drive, the macro is giving me this error.
I did update the One Drive path in A1, but I still get this error below highlighted in red.
Does anyone know of a fix? Do I need a different macro.
I am basically using a master sheet that replicates columns A2 thru AC from 9 (or all if more or less are needed) different files within a folder and merging them together in the master sheet from A8 thru Ac.
Creating one file with all nine files merged together.
Thanks in advance.
Gary
Sub simpleXlsMerger1()
Dim bookList As Workbook
Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object
Application.ScreenUpdating = False
Set mergeObj = CreateObject("Scripting.FileSystemObject")
Set dirObj = mergeObj.Getfolder(Sheets("CG").Range("A1").Value)
Set filesObj = dirObj.Files
For Each everyObj In filesObj
Set bookList = Workbooks.Open(everyObj)
Range("A8:AC" & Range("A65536").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
Application.CutCopyMode = False
bookList.Close
Next
End Sub
This macro works perfectly when I use the file and files being pulled from the C Drive.
But once I moved the file over to the One drive, the macro is giving me this error.
I did update the One Drive path in A1, but I still get this error below highlighted in red.
Does anyone know of a fix? Do I need a different macro.
I am basically using a master sheet that replicates columns A2 thru AC from 9 (or all if more or less are needed) different files within a folder and merging them together in the master sheet from A8 thru Ac.
Creating one file with all nine files merged together.
Thanks in advance.
Gary
Sub simpleXlsMerger1()
Dim bookList As Workbook
Dim mergeObj As Object, dirObj As Object, filesObj As Object, everyObj As Object
Application.ScreenUpdating = False
Set mergeObj = CreateObject("Scripting.FileSystemObject")
Set dirObj = mergeObj.Getfolder(Sheets("CG").Range("A1").Value)
Set filesObj = dirObj.Files
For Each everyObj In filesObj
Set bookList = Workbooks.Open(everyObj)
Range("A8:AC" & Range("A65536").End(xlUp).Row).Copy
ThisWorkbook.Worksheets(1).Activate
Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial
Application.CutCopyMode = False
bookList.Close
Next
End Sub