I am trying to set up a macro that calculates balances per individual per month. When manually setting up the spreadsheet the array formula has returned the correct result but I am getting an error when the formula is included in a macro.
The error message returned is:
"Run-time error '1004':
Unable to set the FormulaArray property of the Range class"
The relevant section of code is:
(please note that I have manually wrapped the code below as when I tried to use the underscore character to wrap the formula I get an immediate syntax error)
The logic of the formula below is that if the values in columns E & F are equal then no value is required (the starting IF stmt). If the values are not equal then the formula will return values from 3 data sheets.
Sheets("Ageing Rpt").Select
Range("G2").Select
Selection.FormulaArray = _
"=IF('Ageing Rpt'!RC[-2]-'Ageing Rpt'!RC[-1]=0,0,
SUM(IF('Comm extracts - cumulative'!R[1]C[3]:R[2000]C[3]
=CONCATENATE('Ageing Rpt'!RC[-6],""/"",EOMONTH(CurMth,-1)),
'Comm extracts - cumulative'!R[1]C:R[2000]C))
+SUM(IF('Manual Adj'!RC:R[2000]C
=CONCATENATE('Ageing Rpt'!RC[-6],""/"",EOMONTH(CurMth,-1)),
'Manual Adj'!RC[-5]:R[2000]C[-5]))
-SUM(IF(Pmts!RC[-1]:R[2000]C[-1]
=CONCATENATE('Ageing Rpt'!RC[-6],""/"",EOMONTH(CurMth,-1)),
Pmts!RC[-4]:R[2000]C[-4])))"
Hopefully someone can make me
Bookmarks