Hello Friends,
I am using the below code which is working perfect apart from the problem that it takes almost 25 seconds when running for first time after I open the workbook. After that when run for the second or third time > it takes only 6 to 7 seconds.
Do you guys have any idea why this is happening.
Any help would be appreciated
Regards,
Humayun
I am using the below code which is working perfect apart from the problem that it takes almost 25 seconds when running for first time after I open the workbook. After that when run for the second or third time > it takes only 6 to 7 seconds.
Do you guys have any idea why this is happening.
VBA Code:
Private Sub update_database()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Run "calculation_off"
Dim ws As Worksheet
Set WSArray = Workbooks("REPORTS.xlsm").Worksheets(Array("INDEX", "DATABASE", "R VALIDATION", "R DAILY PRODUCTION", "R FRI DPI LABTEST", "R PO DESIGN COLOUR"))
For Each ws In WSArray
ws.Unprotect Password:="merchant"
If ws.AutoFilterMode Then ws.AutoFilterMode = False
Next
Workbooks.Open Filename:="C:/OneDrive/Documents/DATA ENTRY.xlsm"
'''''''''''''''''''''''''''''''''''''''''''
Workbooks("REPORTS.xlsm").Worksheets("R VALIDATION").Cells.ClearContents
Workbooks("DATA ENTRY.xlsm").Worksheets("VALIDATION").Cells.Copy
Workbooks("REPORTS.xlsm").Worksheets("R VALIDATION").Range("A1").PasteSpecial Paste:=xlPasteValues
'''''''''''''''''''''''''''''''''''''''''''
Workbooks("REPORTS.xlsm").Worksheets("DATABASE").Range("A2:AO2").ClearContents
Workbooks("REPORTS.xlsm").Worksheets("DATABASE").Range("orders").ClearContents
Workbooks("DATA ENTRY.XLSM").Worksheets("ORDERS").Range("A2:AO10000").Copy
Workbooks("REPORTS.xlsm").Worksheets("DATABASE").Range("A4").PasteSpecial Paste:=xlPasteValues
'''''''''''''''''''''''''''''''''''''''''''
Workbooks("REPORTS.xlsm").Worksheets("R DAILY PRODUCTION").Cells.ClearContents
Workbooks("DATA ENTRY.xlsm").Worksheets("DAILY PRODUCTION").Cells.Copy
Workbooks("REPORTS.xlsm").Worksheets("R DAILY PRODUCTION").Range("A1").PasteSpecial Paste:=xlPasteValues
'''''''''''''''''''''''''''''''''''''''''''
Workbooks("REPORTS.xlsm").Worksheets("R FRI DPI LABTEST").Cells.ClearContents
Workbooks("DATA ENTRY.xlsm").Worksheets("FRI DPI LABTEST").Cells.Copy
Workbooks("REPORTS.xlsm").Worksheets("R FRI DPI LABTEST").Range("A1").PasteSpecial Paste:=xlPasteValues
'''''''''''''''''''''''''''''''''''''''''''
Workbooks("REPORTS.xlsm").Worksheets("R PO DESIGN COLOUR").Cells.ClearContents
Workbooks("DATA ENTRY.xlsm").Worksheets("PO DESIGN COLOUR").Cells.Copy
Workbooks("REPORTS.xlsm").Worksheets("R PO DESIGN COLOUR").Range("A1").PasteSpecial Paste:=xlPasteValues
'''''''''''''''''''''''''''''''''''''''''''
Workbooks("DATA ENTRY.xlsm").Close savechanges:=False
Sheets("INDEX").Range("J16").Value = Now
For Each ws In WSArray
ws.Protect Password:="merchant", DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFormattingColumns:=True, AllowFormattingRows:=True
Next
Application.Run "update_quality_article_unit"
End Sub
Any help would be appreciated
Regards,
Humayun