Hi
I want to know if Eval function available in Excel VBA?
I want to evaluate values like below
st= "0>=15 or 0>=10"
Thanks
Hi
I want to know if Eval function available in Excel VBA?
I want to evaluate values like below
st= "0>=15 or 0>=10"
Thanks
Check out the Evaluate function.
What are you expecting your example to evalute to? As it stands it won't work.
Glen
Why do you need a function?
What exactly should that evaluate to?
[VBA]Sub eval()
Dim st As Boolean
st = 0 >= 15 Or 0 >= 10
MsgBox st
st = 20 >= 15 Or 0 >= 10
MsgBox st
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Hi
Actualy the expression is not a direct value. I am building the expression by checking various conditions and create the expression as string value.
for e.g, after various validations, my expression will be like below
ep="0>15 or 0>10"
now I want to execute the above expression,
if (ep)
{
do something
}
else
{
do otherthing
}
since ep is a string, it gives error in "if". for this scenario VBScript has Eval function which will evaluate the string expression and return the value.
But VBA doesn't have Eval function.
[VBA]Sub eval()
Dim st As String
st = "=or(0 >= 15, 0 >= 10)"
MsgBox Evaluate(st)
st = "=or(0 >= 15, 20 >= 10)"
MsgBox Evaluate(st)
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'