Excel Cell Precedents
Posted on 2010-08-15
I am looking for code that shows how to get the precedent cells for a dependent cell containing a formula. The catch is that the returned precedent cells MUST be in the order in which they appear in the dependent cell's formula.
I have seen and fiddled with plenty of code examples from all over the Internet that suggest using the NavigateArrow method. However, in all such cases the precedent cells are returned in whatever seemingly random order Excel decides--NOT the order in which they appear in the formula.
My current workaround involves regular expression matching on the formula to parse out precedent cell references. This gives me the precedent cells in the order I require. However, the regex matching string is a bit unwieldy, and still misses some precedents.
I'm looking for a solution, or at least something that gets me close to it, in VBA or VB.NET. Thanks.