1

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. Commented May 12, 2015 at 12:10

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.