UDF evaluate string output
Hi Bernie,
I have similar question on using Evaluate and hope you can help me out. I
want to evaluate a text expression in a cell. The function is from web and as
below:
Function yEval(entry As String)
yEval = Evaluate(entry)
End Function
The problem is, it returns the same value to all sheets that are using it.
For example,
In my Sheet1:
A1 = 123
A2 = A1
A3 = yEval(A2)
In my Sheet2:
A1 = abc
A2 = A1
A3 = yEval(A2)
When Sheet1 is active and I press F9, it gives the following results:
Sheet1.A3 = 123
Sheet2.A3 = 123 (supposed to be "abc")
And when Sheet2 is active and I press F9, it gives the following results:
Sheet1.A3 = abc (supposed to be "123")
Sheet2.A3 = abc
Thanks very much!
- LGY
"Bernie Deitrick" wrote:
Function myUDF() As Boolean
Dim myStr As String
myStr = "2+2=4"
myUDF = Application.Evaluate(myStr)
End Function
Sub test()
MsgBox myUDF
End Sub
HTH,
Bernie
MS Excel MVP
"David" wrote in message
...
I'm using a UDF to check the math content of text within a cell
Example: if the cell contains "blah 2+2=4 blah" my UDF will return "2+2=4"
How can I get excel to evaluate my new string so that the output of the UDF
is TRUE or FALSE?
Thanks
|