Hello, I have the following code which (should) create an array.
I want to use this array as part of a WorksheetFunction.SUMIF as the [RANGE SUM] for something like this:
But currently its not working and throwing up an application defined run time error. Any help in figuring this out would be much appreciated.
VBA Code:
Function UnitCheckArr()
Dim UnitValueArr(2 To 250) As Long
Dim UnitValue As Long
For UnitValue = LBound(UnitValueArr) To UBound(UnitValueArr)
UnitValueArr(UnitValue) = Cells(UnitValue, 4) * Cells(UnitValue, 6)
Next UnitValue
End Function
I want to use this array as part of a WorksheetFunction.SUMIF as the [RANGE SUM] for something like this:
VBA Code:
Sub NetSumIF()
If [COUNTA(F2:F250)=0] Then
Worksheets("Sheet1").Range("K2:K250") = Application.WorksheetFunction.SumIf(Worksheets("Sheet1").Range("I2:I250"), "I2:I250", Worksheets("Sheet1").Range("UnitCheckArr"))
End If
End Sub
But currently its not working and throwing up an application defined run time error. Any help in figuring this out would be much appreciated.