Evaluate Excel VBA boolean condition (not a formula)

前端 未结 3 512
孤城傲影
孤城傲影 2021-01-13 17:02

I have text in a cell A1 as below

((True And False Or True) And (True And (Not True))) And (False Or True)

I need to evalu

3条回答
  •  迷失自我
    2021-01-13 17:26

    You could try something like this, taking advantage of the Eval function in Access.

    Public Function EvaluateExpression(Value As String) As Boolean
        With CreateObject("Access.Application")
            EvaluateExpression = .Eval(Value)
        End With
    End Function
    
    Public Sub T()
        Debug.Print EvaluateExpression("((True And True Or True) And (True And (True))) And (True Or True)")
    End Sub
    
    'True
    

提交回复
热议问题