I have 2 workbooks, 'old' & 'new'. Both are identical (both have the same sets of worksheets - worksheet names and all - with identical formulas)
I'm trying to import Sheet A from 'old' to 'new'. The way I'm doing this is deleting the Sheet A from 'new' and then copying the whole worksheet (i.e. Sheet A of 'old' ) from 'old' to 'new'
wkbOld.worksheets("Sheet A").Copy After:=wkbNew.Worksheets(nPos)
'nPos is the position of Sheet A in these workbooks
Sheet A has Formulas referring to cells in Sheet B. I also have a Sheet Z that has formulas referring to cells in Sheet A.
While Importing I'm turning off Calculation for all the worksheets present in 'new' (toggleAutomaticCalculation false). I'm turning on automatic calculation after I've 'Imported' my sheet (toggleAutomaticCalculation true). I'm Using the following sub for toggling automatic calculation.
Public Sub toggleAutomaticCalculation(bToggle As Boolean)
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
wks.EnableCalculation = bToggle
Next wks
End Sub
After I've done my 'Importing', I find #REF Errors in Sheet Z in 'new', on those cells that had formulas referring to Sheet A, but the formulas in the now imported Sheet A are working fine (i.e. they are now linking to Sheet B in new)
My Macros for import are present in 'new', from where I'm running them.
My Questions are as follows:
Why is #REF error happening in Sheet Z while it's not happening in Sheet A, though both sheets contain formulas referring to external sheets?
Is there a way to prevent #REF errors in Sheet Z?
My only option currently is to again put back the original formulas in Sheet Z (using a separate sub) post importing.
I'm using Excel 2013 and I want this to work in Excel 2013.
Kindly help.