vba - How to evaluate typed-out formulas in Excel -


if type formula 1/4*pi()*($a$1)^2 string in cell , assuming have value in $a$1, use following vba function in third cell evaluate formula:

public function e(byval textformula string) variant   e = evaluate(textformula) end function   

is there way use math characters •, √, ¼, π, ², etc. typed-out formula looks more agreeable? translate '[' , ']' '(' , ')'. can iterate through array replacements using replace() function simple characters extended characters π?

for sharp macro'ers...

what showing intermediate steps (iterations) in (2*3) + (2.5*4) evaluates 6 + 10 in first iteration , 16 in next iteration. asside: want iterations stop before each set of addings/subtractings because know relative magnitudes of individual evaluated terms see part of formula controlling result.

and mega-genius ones...

what mixed units? such typing out 560{lbs}/[1.23{m}*3.4{'}] , getting result in ###{psf} example. thought unit delineated underscore such 34_kn think start , end delineation required compound units 34{kn/m^2}. there need way force output desired unit (ie. mm instead of in) maybe setting desired units ahead in sheet , @ least try convert 1 of units. think @ stage charging me code;)

i using excel engineering calculations because use simpler formulas (no calculus!) , don't want switch between excel , mathcad apps use one.

shawn

those tall orders. following sub might give idea first question:

sub test()     dim r range     set r = range("a1")     r.value = "a = pr2"     r.characters(5, 1).font.name = "symbol"     r.characters(7, 1).font.superscript = true end sub 

run @ contents of a1

as far second question goes - sure can it, need write full-fledged expression parser. writing 1 scratch involved (at least couple hundred lines of code) , best done using classes create custom tree data type writing recursive descent parser parse strings expression trees. doable, though have neither time nor inclination so.

i'm not quite sure driving @ last question, though gut reaction is easier second question since no real parsing required , easy enough create dictionary of conversion factors.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -