I have come across a very strange scenario. In a function I will receive a string of condition to be evaluated.
E.g.
(a>b and (b=2 or c!=3))
Here's a proper answer to your question, rather than just a comment.
You need to:
Microsoft Visual Basic for Applications Extensibility x.x
(Tools/References) in the VBIDE.initValues()
then call getConstantValue("(a>b and (b=2 or c<>3))")
Code:
Option Explicit
Dim a As Long
Dim b As Long
Dim c As Long
Sub initValues()
a = 3
b = 2
c = 4
End Sub
Function getConstantValue(constStr As String) As Variant
Dim oMod As VBIDE.CodeModule
Dim i As Long, _
num As Long
Set oMod = ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
For i = 1 To oMod.CountOfLines
If oMod.Lines(i, 1) = "Function tempGetConstValue() As Variant" Then
num = i + 1
Exit For
End If
Next i
oMod.InsertLines num, "tempGetConstValue = " & constStr
getConstantValue = Application.Run("tempGetConstValue")
oMod.DeleteLines num
End Function
Function tempGetConstValue() As Variant
End Function