Dynamic formula


Posted by Dean on January 31, 2002 10:30 PM

I want to store an Excel formula as text in a cell and then use a VBA macro to pickup the text and execute it just as if Excel were executing it as a true cell formula. Anyone know if this can be done? It's kinda like a dynamic formula, change the text in the cell and the formula changes.

Posted by Tom Urtis on January 31, 2002 10:52 PM

Let's say in cell A1 you enter B1+C1-D1, looking like a formula but without the equals sign that precedes a formula. That value would be a text entry in cell A1, as you say you want to do. So, maybe this macro with one line of code might do the trick.

Sub FormulaFun()
ActiveCell.Formula = "=" & [A1]
End Sub

If I misunderstood your question, sorry, please repost.

Tom Urtis

Posted by Tom Urtis on January 31, 2002 10:58 PM

Gremlins in cyberland

OK, the example text formula entry I posted did not appear as I typed it; a space is needed between operators on this site.

My first sentence should read:

Let's say in cell A1 you enter B1 + C1 + D1 , ...


Tom U.



Posted by Mark W. on February 01, 2002 6:54 AM

It's only the < operator that's problematic...

...this site treats &LT; as the beginning of a tag.