MalusPuer
MalusPuer

Reputation: 31

Using variable in excel formula

I have a formula in my VBA code in which I would like to embed a variable. I defined an integer but am unsure how to add it to my formula.

 Dim Formula as Variant
 Dim Stability as Integer
 Stability = 0.5
 Formula = Application.WorksheetFunction.AverageIfs(range("C:C"), range("C:C"), ">=10", range("C:C"), "<=15", range("F:F"), "<=Stability")

At the end of the formula I want to include my Stability variable. What is the correct syntax for doing so?

Upvotes: 1

Views: 89

Answers (1)

user2140173
user2140173

Reputation:

try

Formula = ..., "<=" & Stability)

Upvotes: 2

Related Questions