Jesper, welcome to the board, an interesting question.
I'm sure there are clever ways of doing this but to be honest I wouldn't lay claim to knowing them myself - in reality what you're looking to do is evaluate each variable and replace with resulting constant (per F9 functionality in the Formula Bar).
Based on the very basic example you offer, if it's that trivial:
the FnK function can then be called along the lines of:
where A1 contains the actual formula of interest
note: in the above (much simplified scenario) we are assuming all range references to be local to the active sheet and an environment prior to XL2007 (if not change {1,2} to {1,2,3})
so to reiterate this is meant as nothing more than a possible way forward re: future development.
edit: further major caveat - the above is per the example looking at references as single cell references and is not catering for ranges (eg B115:B120) - to reiterate this is not intended to be an all singing all dancing solution
a more robust solution would be to iterate the formula string based on known delimiters (+,-,(, ) etc...) and determine each component part (where running balance of delimiters is 0) evaluating each in turn.
Bookmarks