nyconfidential
New Member
- Joined
- Jul 22, 2015
- Messages
- 49
- Office Version
- 365
- 2016
Hi - I've been tasked with finding a way to copy all of the formulas from one workbook(that has all the correct formulas and links) to another workbook(it's an exact copy of the first workbook, but it contains lots of broken formula links). I'm able to do it using the code below - basically I'm looping through each cell in the clean workbook, copying it's formula, then setting the formula in the accompanying cell in the workbook with the broken formulas. Seems to work ok - but I'd like it to be faster(the Workbooks have 60+ sheets). Is there a faster alternative? Would sticking the formulas in Variant arrays speed things up?
Code:
For Each rCell In rRng.Cells ' Loop through a list of all the Worksheets
If SheetExists(rCell.Value) = True Then
Application.DisplayAlerts = False
Application.ScreenUpdating = False
frmlaCnt = ThisWorkbook.Sheets(rCell.Value).Cells.SpecialCells(xlCellTypeFormulas).Count
If frmlaCnt > 0 Then
For Each r In ThisWorkbook.Sheets(rCell.Value).Cells.SpecialCells(xlCellTypeFormulas)
ActiveWorkbook.Sheets(rCell.Value).Range(r.Address).Formula _
= ThisWorkbook.Sheets(rCell.Value).Range(r.Address).Formula
Next r
End If
End If
Debug.Print rCell.Value & " " & frmlaCnt
ActiveWorkbook.Sheets(rCell.Value).Calculate
Next rCell
Last edited: