I am trying to find specific formulas in an Excel workbook. Cycling through all the cells of all the sheets wouldnt make any sense (too long). I found something like a Formula "Array" in the Range Object (I'm using the UsedRange for all references), that seems to list all formulas in the workbook. Can somebody give me an example how to cycle though these formulas?
This test function doesnt seem to work:
Function cleanup()
Dim rng As Range, sheet As Worksheet, intCounter As Long, varFormula1 As Variant, varFormula2 As Variant
Set rng = Sheets("testsheet"
.UsedRange
For Each varFormula1 In rng.Formula
Debug.Print varFormula1
If InStr(1, varFormula, "=S"
> 0 Then
MsgBox "found reference formula: " & varFormula1
End If
Next varFormula1
End Function
This test function doesnt seem to work:
Function cleanup()
Dim rng As Range, sheet As Worksheet, intCounter As Long, varFormula1 As Variant, varFormula2 As Variant
Set rng = Sheets("testsheet"
For Each varFormula1 In rng.Formula
Debug.Print varFormula1
If InStr(1, varFormula, "=S"
MsgBox "found reference formula: " & varFormula1
End If
Next varFormula1
End Function