Array formula in VBA sheet

alanhather

New Member
Joined
Feb 2, 2018
Messages
24
Hi all,

I'm trying to input this array formula in VBAand its filling in the cell C180. Any ideas?

The sheet5 is called admissons

Sub Array_Formula()


Range("C180").Select
Selection.FormulaArray = "=SUM(--(FREQUENCY(IF('Raw Data Prev Year'!$B:$B<>"",IF('Raw Data Prev Year'!$D:$D=A180,IF('Raw Data Prev Year'!S:S>=$B$167,IF('Raw Data Prev Year'!$S:$S<=$C$167,MATCH('Raw Data Prev Year'!$B:$B,'Raw Data Prev Year'!$B:$B,0))))),ROW('Raw Data Prev Year'!$B:$B)-ROW('Raw Data Prev Year'!$B$1)+1)>0))"


End Sub

Thanks
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
What is that formula meant to do? It just looks like its can only produce a 1 or a 0 based on whether the conditions exist or not. For that a countif may be better. Anyway it wont work because its too long as an array formula for VBA to handle. Its possible to get around that but first say what its meant to be doing.
 
Upvote 0
Hi - this is counting a certain name within a date range between certain dates but counting a unique ID once if duplicated. It works but thought it would be better through VBA.
 
Upvote 0
Yeah so its checking if all the conditions are met and if so produces a 1 and if not a 0? See if this produces the same results. It doesnt need array entry:

=0+(COUNTIFS('Raw Data Prev Year'!$D:$D,A180,'Raw Data Prev Year'!$B:$B,"<>",'Raw Data Prev Year'!S:S,">="&$B$167,'Raw Data Prev Year'!S:S,"<="&$C$167)>0)
 
Upvote 0
Hi as you said this is producing 1 - it should produce 16 as i have 17 records but 1 of them is a duplicate so the array formula counted it as 1 and returned 16.
 
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,594
Members
452,656
Latest member
earth

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