3 ms·
I wrote a VBA function that returns the formula of a cell as a string, or "const" if the cell is not a formula, or "empty" if the cell is empty. (The latter is
by analog31 5y ago
I wrote a VBA function that returns the formula of a cell as a string, or "const" if the cell is not a formula, or "empty" if the cell is empty. (The latter is useful for finding bugs). Then I use it to display the formula in the cell immediately adjacent to where the formula actually resides. It's not a panacea, but overcomes the problem of "the code is invisible when reading a spreadsheet."
I don't remember the macro, it was more than a decade ago. Something along the lines of:
function foo(c)
s = c.Formula
' do something with s
foo = s
Then in a cell, I could write something like:
=foo(A32)