Reputation: 1
Hi I have created a quick function that evaluate string
Function Evalue(ByVal str As String)
Application.Volatile
Evalue = Evaluate([str])
End Function
I have an array with all the formulas I use as string. Depending on the case I use INDEX/MATCH to choose the good formula then Evalue to evaluate it.
If the string formula is in 1 block like SUM(A1:A20) it works perfectly But if it is in several blocks like
SUM(A1:A20)-SUM(B1:B20
) it returns a #NAME
error, if I put the string in the array between ' '
or " "
it returns #VALUE
error.
Upvotes: 0
Views: 360
Reputation:
** snip ** The original code works just fine as written.
The cell I tested looked like this:
=Evalue("SUM(A1:A3)-SUM(B1:B3)")
Here's the security problem:
Apparently the first time you open and save a workbook, storing code in a module is enough to make it accessible to be run from within worksheet cells. However, the next time you open the same worksheet (even if it is macro enabled) it's very much more difficult to get things working again. Apparently the original code works fine as written. However, Excel hints it exists and then reports a #NAME error when you try to use it. There's a thread here with more info:
Apparently it requires installing an "add-in" to perform the simplest operation. (Or you can use your personal.xlsb file)
Upvotes: 2