Need help using array formula in VBA

dryper

Board Regular
Joined
Nov 27, 2009
Messages
50
I have the following array formula which I want to convert into a UDF:

Code:
={SUM(IF(ISNUMBER(AB10:AF10),AB10:AF10/AB$5:AF$5*AB$6:AF$6))/SUMPRODUCT(AB$6:AF$6,(AB10:AF10<>"MC")*1,(AB10:AF10<>"VR")*1)}

Read that ActiveSheet.Evaluate can be used to evaluate array formula, so I created this function in VBA:

Code:
Function SUPER1(score As Range, total As Range, weight As Range)
    
    SUPER1 = ActiveSheet.Evaluate("=SUM(IF(ISNUMBER(score),score/total*weight))/SUMPRODUCT(weight,(score<>""MC"")*1,(score<>""VR"")*1)")

End Function

But I keep getting #NAME? error in cells with the following formula:

Code:
=SUPER1(AB10:AF10,$AB$5:$AF$5,$AB$6:$AF$6)

Please help. Thanks.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try something like this (not tested)...

Code:
Function SUPER1(score As Range, total As Range, weight As Range)
    
    SUPER1 = ActiveSheet.Evaluate("SUM(IF(ISNUMBER(" & score.Address & ")," & score.Address & "/" & total.Address & "*" & weight.Address & "))/SUMPRODUCT(" & weight.Address & ",(" & score.Address & "<>""MC"")*1,(" & score.Address & "<>""VR"")*1)")

End Function
 
Upvote 0
Try something like this (not tested)...

Code:
Function SUPER1(score As Range, total As Range, weight As Range)
    
    SUPER1 = ActiveSheet.Evaluate("SUM(IF(ISNUMBER(" & score.Address & ")," & score.Address & "/" & total.Address & "*" & weight.Address & "))/SUMPRODUCT(" & weight.Address & ",(" & score.Address & "<>""MC"")*1,(" & score.Address & "<>""VR"")*1)")

End Function

Great. Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,270
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top