KIM Chanthan
Member
Hi,
I have run VBA code to consolidate all files into each sheet in one master file.
It works perfectly when i test few files, but when i start with many files, error message alert as below:
Can you please help to comment on below code:
-----------------------------------------------------
>>> use code - tags <<<
------------------------------------------
Thanks for help.
I have run VBA code to consolidate all files into each sheet in one master file.
It works perfectly when i test few files, but when i start with many files, error message alert as below:
Can you please help to comment on below code:
-----------------------------------------------------
>>> use code - tags <<<
Code:
Sub ConsolidateBPbyccy()
Dim FolderPath As String
Dim Filename As String
Dim Sheet As Worksheet
Application.ScreenUpdating = False
FolderPath = ActiveWorkbook.Path & "\"
Filename = Dir(FolderPath & "*.xlsx*")
D = 1
Do While Filename <> ""
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
Workbooks.Open Filename:=FolderPath & Filename, ReadOnly:=True
' For Each Sheet In ActiveWorkbook.Sheets
Sheets(2).Copy After:=ThisWorkbook.Sheets(D)
Application.AskToUpdateLinks = True
Application.DisplayAlerts = True
' Next Sheet
Workbooks(Filename).Close Savechanges:=False
ActiveSheet.Name = Range("B4").Value
Filename = Dir()
D = D + 1
Loop
Application.AskToUpdateLinks = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
------------------------------------------
Thanks for help.
Last edited by a moderator: