1
votes

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
Your explanation is too scarce. Please provide a screenshot or elaborate more.AnalystCave.com

1 Answers

3
votes

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:

enter image description here