我有一张包含数组公式的工作表。
我在互联网上找到了一些刷新功能的代码(重新计算数组中的所有公式。
我遇到的问题是它会导致无限的计算循环。
有人可以建议一种方法来阻止代码进入这个无限循环吗?
Sub RefreshAllFormulas()
Dim i As Integer
Dim CurCell As Object
Dim lastCellFx As Object
MousePointer = fmMousePointerHourGlass
Total = 0
For i = 1 To ActiveWorkbook.Sheets.Count
Subtotal = 0
On Error Resume Next
Sheets(i).Activate
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
For Each CurCell In Selection
If lastCellFx.Formula <> CurCell.Formula Then
CurCell.Activate
mnuRefreshSelection
Set lastCellFx = CurCell
End If
Next CurCell
Next i
MousePointer = fmMousePointerDefault
Sheets(1).Activate
End Sub