G
Guest
I am pretty new to declaring variables etc. Generally, I have let VBA use
defaults and not worried about declaring anything, but in an effort to reduce
file sizes and increase speeds I am expiermenting. What is wrong with the
code below? When I didn't define Var1 and just used J1 in the formula, it
worked fine. ???
Private Sub CommandButton1_Click()
Dim Ans As Range
Dim Var1 As Range
Set Ans = Worksheets("Sheet1").Range("h2")
Set Var1 = Worksheets("Sheet1").Range("J1")
Ans.Value =
Worksheets("sheet1").Evaluate("=SUMPRODUCT((A1:A10=Var1)*(B1:B10=k1)*(C1:C10=L1)*(D1:F10>2))")
End Sub
defaults and not worried about declaring anything, but in an effort to reduce
file sizes and increase speeds I am expiermenting. What is wrong with the
code below? When I didn't define Var1 and just used J1 in the formula, it
worked fine. ???
Private Sub CommandButton1_Click()
Dim Ans As Range
Dim Var1 As Range
Set Ans = Worksheets("Sheet1").Range("h2")
Set Var1 = Worksheets("Sheet1").Range("J1")
Ans.Value =
Worksheets("sheet1").Evaluate("=SUMPRODUCT((A1:A10=Var1)*(B1:B10=k1)*(C1:C10=L1)*(D1:F10>2))")
End Sub