Formula Array

goldie12

Board Regular
Joined
Apr 19, 2005
Messages
105
Can someone tell me how you go about using the formula array in VBA? I have the following code:




VBA:

Range("N10").FormulaArray = _
"=SUM((Miles>=R9C)*(Miles<R9C[1])*(Depth<=RC13)*(Depth>R[1]C13))"



I keep getting an error message stating that "Unable to apply Array Formula" and "Invalid name error"? Any suggestions on how to set the array formula in VBA

Thanks
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
You're missing an operator in your second criterion.
Perhaps you want Miles=R[1]C13 instead of MilesR[1]C13 ?
 
Upvote 0
Sorry I listed the wrong code. It should be:

Range("N10").FormulaArray = _
"=SUM((Miles>=N$9)*(Miles<O$9)*(Depth<=$M10)*(Depth>$M11))"

Selection.AutoFill Destination:=Range("N10:N16"), Type:=xlFillDefault

This is the code that I am having problems with. Any suggestions. Thanks
 
Upvote 0
Same comment though... Assuming miles is a named range, your second criterion still needs an operator.

Miles$M11 should probably be Miles=$M11
 
Upvote 0
Sorry again for some reason I can't seem to post the whole line of the code: Let me try this again:\


Code:
Range("N10").FormulaArray = _
"=SUM((Miles>=N$9)*(Miles<O$9)*(Depth<=$M10)*(Depth>$M11))"
Selection.AutoFill Destination:=Range("N10:N16"), Type:=xlFillDefault

I get the following error message:

Runtime error '1004'
Unable to set the FormulaArray property of the Range Class
 
Upvote 0
You may want to use a range instead of "selection" in your fill, but this works fine for me:

Code:
Range("N10").FormulaArray = _
"=SUM((Miles>=N$9)*(Miles<O$9)*(Depth<=$M10)*(Depth>$M11))"
Range("N10").AutoFill Destination:=Range("N10:N16"), Type:=xlFillDefault
 
Upvote 0

Forum statistics

Threads
1,215,129
Messages
6,123,210
Members
449,090
Latest member
bes000

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