在我的工作表中,我有数百个独特的公式(简单和数组)。一些单元格包含数组公式和一些简单的公式。我不得不批量编辑(查找和替换)所有公式中的一些字符。我将它们作为文本导出到notepad++,并完成了替换工作,并将它们带回并粘贴到工作表上。当我按‘计算工作表’或alt + ctrl +f9时,它不会更新数组公式。有没有任何方法来更新(刷新)所有的公式?还是我应该一个接一个地去按ctrl+shift+enter?考虑到我有多少细胞,这是不可行的。我怎么才能用vba做这件事?谢谢
发布于 2014-11-12 13:09:30
你需要一个这样的例程-它可能需要一段时间重新计算在结束时,它的声音!
Sub AddErrorHandler()
Dim rngFormulas As Range
Dim rngCell As Range
Dim lngCalcMode As Long
On Error Resume Next
Set rngFormulas = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas)
On Error GoTo 0
If Not rngFormulas Is Nothing Then
With Application
.ScreenUpdating = False
lngCalcMode = .Calculation
.Calculation = xlCalculationManual
End With
For Each rngCell In rngFormulas.Cells
If LCase$(Left$(rngCell.Formula, 9)) <> "=iferror(" Then
If rngCell.HasArray Then
With rngCell.CurrentArray
.FormulaArray = "=IFERROR(" & Mid$(.FormulaArray, 2) & ",0)"
End With
Else
With rngCell
.Formula = "=IFERROR(" & Mid$(.Formula, 2) & ",0)"
End With
End If
End If
Next rngCell
With Application
.Calculation = lngCalcMode
.ScreenUpdating = True
End With
End If
End Subhttps://stackoverflow.com/questions/26885956
复制相似问题