Excel Formula:

`{=SUM(--(FREQUENCY(IF(MONTH(DataCreated)=B3,MATCH(DataAccount,DataAccount,0)),ROW(DataAccount)-ROW(Data!D6)+1)>0))}`

This formula works perfectly.

I want to calculate the same but by quarter. To do so I created a simple function in VBA to calculate the quarter, titled CalcQuarter, and I created the following formula for Q1:

Excel Formula:

`{=SUM(--(FREQUENCY(IF(CalcQuarter(DataCreated)=1,MATCH(DataAccount,DataAccount,0)),ROW(DataAccount)-ROW(Data!D6)+1)>0))}`

Unfortunately, this formula returns #VALUE. Note that the only difference between the two formulas is that the first uses the MONTH function and the second uses the CalcQuarter function that I wrote.

Because the formulas are so similar, all I could think of is that the array formula does not like the user defined function.

Any thoughts on why the second formula does not work or how to correct?

Thanks!