AW: Mit Makro Formeln ergänzen
12.03.2012 11:23:49
Tino
Hallo,
kannst diesen Code mal testen, Tabelle und den Bereich für die Formel noch anpassen.
Sub Formel_Erweitern()
Dim rngFormelBereich As Range, rngTmp As Range, ArrayFormel()
Dim n&, nn&, iCalc%
With Tabelle1 'Tabelle anapssen
On Error Resume Next
'Bereich wo die Formeln stehen, evtl. anpassen
Set rngFormelBereich = .Columns(1).SpecialCells(xlCellTypeFormulas, 23)
On Error GoTo 0
End With
If Not rngFormelBereich Is Nothing Then
With Application
iCalc = .Calculation
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
For Each rngTmp In rngFormelBereich.Areas
With rngTmp
ArrayFormel = .Resize(, .Columns.Count + 1).FormulaR1C1
Redim Preserve ArrayFormel(1 To Ubound(ArrayFormel), 1 To Ubound(ArrayFormel, 2) - 1)
For n = 1 To Ubound(ArrayFormel)
For nn = 1 To Ubound(ArrayFormel, 2)
ArrayFormel(n, nn) = "=IFERROR(" & Replace(ArrayFormel(n, nn), "=", "") & ",0)"
Next nn
Next n
.FormulaR1C1 = ArrayFormel
End With
Next rngTmp
.Calculation = iCalc
.EnableEvents = True
.ScreenUpdating = True
End With
Else
MsgBox "keine Formel in diesem Bereich!"
End If
End Sub
Gruß Tino