New VBA user here, thank you for your patience. I want to copy and paste as values a range from a single closed worksheet to an active worksheet. Specifically, I want to use VBA in an active workbook to copy range A1:HW6000 from the "AllData" tab in TOOL.XLSM while TOOL.XLSM is closed and paste into the active workbook in range A1:HW6000 in the active sheet as values.
I have code that will do this (care of Peh at stackoverflow, thank you Peh!), but the code runs forever (more than 45 minutes), because running the code seems to recalculate both the new workbook and the import workbook at the same time, and the import workbook (TEST.xslm) is very large. I am running on a Mac. Here is the code I currently have:
Sub ImportData()
Dim App As New Excel.Application 'create a new (hidden) Excel
' remember active sheet
Dim wsActive As Worksheet
Set wsActive = ThisWorkbook.ActiveSheet
' open the import workbook in new Excel (as read only)
Dim wbImport As Workbook
Set wbImport = App.Workbooks.Open(Filename:="/Users/cwight/Desktop/TOOL.xlsm", UpdateLinks:=True, ReadOnly:=True)
'copy the data of the import sheet
wbImport.Worksheets("AllDATA").Range("A1:HW6000").Copy
wsActive.Range("A1").PasteSpecial Paste:=xlPasteFormats 'paste formats
wsActive.Range("A1").PasteSpecial Paste:=xlPasteValues 'paste values
App.CutCopyMode = False 'clear clipboard (prevents asking when wb is closed)
wbImport.Close SaveChanges:=False 'close wb without saving
App.Quit 'quit the hidden Excel
End Sub
Can I integrate the following bits of code to turn off the calculation during the import process? If so, how exactly? I cannot figure it out:
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Is there anything else I can do? Thank you tremendously for your time.
Set wbImport = ....
Do remember to turn them back to true at the end of your code. – Luuklag