Displaying parsed formulas

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Displaying parsed formulas

Post by ChrisGreaves »

Please see Backus–Naur Form (BNF) of Excel formulae and Fixing ugly workbooks (Excel 2000+).

Here is another use (attached) of Rob Van Gelder's SUPERB tokeniser.
I was asked to portray cell constants in a readable manner, so the macro TESTAnnotateCell offers a single cell to the function AnnotateRange.
The proof-of-concept is severely limited and works best when
(1) Formulas are running vertically down the sheet, one formula per row (in a calculation sheet I usually have the goal at the bottom, drawing ever-upwards on earlier (lower-row-number) calculations)
(2) Range names are used (AnnotateRange inserts two rows, so if you are using cell references you'd be best advised to start at the bottom and work your way upwards so as not to corrupt cell references each time AnnotateRange inserts two rows).

I have to think about :-
(i) Multiple formulas on a single row.
(ii) Use font/coding to indicate nesting level
(iii) Cell width problem

Unzip the attachment to a fresh folder. Open the two workbooks and the VBE. Place the cell pointer on cell E14 of the worksheet "Sheet1" in the workbook "Report On Sales.xls", then run the macro TESTAnnotateCell.
I have previously run the macro on the two cells below cell E14, so you can see what you're aiming for.
1.JPG
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.