I'm trying to add IFERROR to all cells within a selection, but only if the cell does not already have IFERROR. I have a VBA code that does that, but unfortunately it takes hours to run as it loops through 1.5 million cells. Also, I always have to change the range within the Macro, but I would prefer a more 'flexible' method where it checks all cells within a current selection on a certain sheet. Can anyone help me simplify/speed up the code? Also, I'm using Excel 2016 and noticed that my codes slowed down even more when using below code compared to Excel 2010 (1~ hour to now 3~ hours roughly).
Sub IFERRORTOALLCELLS() 'Optimize Code Call OptimizeCode_Begin Dim myRange As Range Dim cell As Range ' Set range to apply this to Set myRange = Range("A1:FQ432") ' Loop through range For Each cell In myRange ' Check to see if formula (and not already if error) If Left(cell.Formula, 1) = "=" And Left(cell.Formula, 8) <> "=IFERROR" Then cell.Formula = "=IFERROR(" & Mid(cell.Formula, 2, Len(cell.Formula) - 1) & ",0)" End If Next cell 'Optimize Code Call OptimizeCode_End End Sub