1

For example:

I have this formula in A1: 2*x+3*x

and this formula in B1: =SUBSTITUTE($A$1,"x",E1) so my output in B1 is 2*1+3*1

Now, what I'd like is to have that operation evaluated so that it shows 5 instead of 2*1+3*1

I don't mind if it's on the same cell or on a different one, but how can I do it?

I tried with =VALUE(B1) but it gives me an error, I tried with =INDIRECT("B1",0) but it gives me an error too. I'm not familiar with these functions so I'm not really sure they are what I need. Any suggestions?

I'd like to do it without using Macros, if possible.

Thanks!

Guss Ino
  • 21
  • 2

1 Answers1

2

You could use a small UDF

Function Eval(exp As String)

    Dim rv
    rv = Application.Evaluate(exp)
    Eval = IIf(IsError(rv), CVErr(xlValue), rv)

End Function

Then in the worksheet:

=Eval(SUBSTITUTE(B4,"x",5))
Tim Williams
  • 154,628
  • 8
  • 97
  • 125
  • I get a "BASIC runtime error. Object variable not set" from this line: rv = Application.Evaluate(exp) – Guss Ino May 30 '12 at 22:17