imkumarvikash
New Member
- Joined
- May 5, 2017
- Messages
- 8
I am trying to use the following Array Formula in my VBA.
Range(Cells(2, "AF"), Cells(4, Col)).FormulaArray = "=IF(COLUMNS($AF2:AF2)<=$AE2,INDEX('Demand File '!$A$2:$A$3001,SMALL(IF('Demand File '!$CC$2:$CC$3001=CONCAT($J2,$K2,$L2,""Yes""),ROW('Demand File '!$A$2:$A$3001)-ROW('Demand File '!$A$2)+1),COLUMNS($AF2:AF2))),"")"
It's giving me an error - 'Unable to set the FormulaArray property of Range class'
However, the below formula works fine (logic not correct, just testing syntax)
Range(Cells(2, "AF"), Cells(lRow, Col)).FormulaArray = "=IF(COLUMNS($AF2:AF2)<=$AE2,INDEX('Demand File '!$A$2:$A$3001,SMALL(IF('Demand File '!$J$2:$J$3001='Swap List '!$J2,ROW('Demand File '!$A$2:$A$3001)-ROW('Demand File '!$A$2)+1),COLUMNS($AF2:AF2))),"""")"
Range(Cells(2, "AF"), Cells(4, Col)).FormulaArray = "=IF(COLUMNS($AF2:AF2)<=$AE2,INDEX('Demand File '!$A$2:$A$3001,SMALL(IF('Demand File '!$CC$2:$CC$3001=CONCAT($J2,$K2,$L2,""Yes""),ROW('Demand File '!$A$2:$A$3001)-ROW('Demand File '!$A$2)+1),COLUMNS($AF2:AF2))),"")"
It's giving me an error - 'Unable to set the FormulaArray property of Range class'
However, the below formula works fine (logic not correct, just testing syntax)
Range(Cells(2, "AF"), Cells(lRow, Col)).FormulaArray = "=IF(COLUMNS($AF2:AF2)<=$AE2,INDEX('Demand File '!$A$2:$A$3001,SMALL(IF('Demand File '!$J$2:$J$3001='Swap List '!$J2,ROW('Demand File '!$A$2:$A$3001)-ROW('Demand File '!$A$2)+1),COLUMNS($AF2:AF2))),"""")"