I have some excel sheets with calculated fields, e.g. CELL_C =FIELD_A+FIELD_B. I need to extract all cells from that formula for highlight it with different color. Is there any built-in VBA function to parse cell.Formula to get the range of cells?
1 Answer
You can always get the first-level precedents with something like:
Sub qwerty()
Dim rng As Range
Set rng = ActiveCell.Precedents
If rng Is Nothing Then
Else
MsgBox rng.Address(0, 0)
End If
End Sub
For example:

3 Comments
FreeMan
Thanks, Gary - I didn't know about
.Precedents - looks very useful!Gary's Student
@FreeMan There are some restrictions associated with .Precedents.
brettdj
need to use NavigateArrows to find off sheet precedents