Stop VBA Evaluate from calling target function twice

后端 未结 6 868
自闭症患者
自闭症患者 2020-12-06 06:45

I am having trouble getting VBA\'s Evaluate() function to only execute once; it seems to always run twice. For instance, consider the trivial example below. If we run the Ru

6条回答
  •  抹茶落季
    2020-12-06 07:47

    After seeing there is no proper way to work around this problem, I solved it by the following:

    Dim RunEval as boolean
    
    Sub RunEval()
        RunEval = True
        Evaluate "EvalTest()"
    End Sub
    
    Public Function EvalTest()
        if RunEval = true then
         Debug.Print Rnd()
         RunEval = False
        end if
    End Function
    

    problem solved everyone.

提交回复
热议问题