Diego
Diego

Reputation: 105

VBA Evaluate with excel formula

how can I use VBA to Evaluate my string and apply a RoundUp in order to obtain "6" as a result

Sub EvaluateExample()
    Dim r As String
    r = "ROUNDUP(11/2)"
    Debug.Print Evaluate(r)
    'should print "6"
End Sub

Upvotes: 0

Views: 181

Answers (1)

JohnyL
JohnyL

Reputation: 7122

You are missing an argument in your ROUNDUP() call (number of digits after the decimal). Here's the correct way to do it:

r = "ROUNDUP(11/2,0)"

Upvotes: 3

Related Questions