Converting ArrayFormula to VBA

Rubsie

New Member
Joined
Feb 16, 2009
Messages
7
Hi,

I have this working arrayformula in excel (only one sheet in the .xls):

{=SUM(IF((C5:C25<3);G5:G25;0))-SUM(IF((C5:C25<3)+IF(ISNUMBER(SEARCH("*flat*";I5:I25;1));1;0)=2;G5:G25;0))}

What I want to do now is to execute this array formula using VBA and store the result in cell A1.

I tried this code:

Range("A1").FormulaArray = "=SUM(IF((C7:C27<3);G7:G27;0))-SUM(IF((C7:C27<3)+IF(ISNUMBER(SEARCH(""*flat*"";I7:I27;1));1;0)=2;G7:G27;0))"

But with this, I always get the Runtime 1004 error.

Can anyone help me solve this problem?
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi

Try it with commas instead of semi-colons:

Code:
Range("A1").FormulaArray = "=SUM(IF((C7:C27<3),G7:G27,0))-SUM(IF((C7:C27<3)+IF(ISNUMBER(SEARCH(""*flat*"",I7:I27,1)),1,0)=2,G7:G27,0))"
 
Upvote 0
Incidentally, you could shorten your formula to:
=SUMPRODUCT(--(C5:C25<3);--(ISERROR(SEARCH("*flat*";$I$5:$I$25)));G5:G25)

which does not need to be array-entered.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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