Insert formula in range of cells through VBA Code

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,531
Office Version
  1. 2016
Platform
  1. Windows
Hello Firends,

I am trying to insert the formula in the range of cells through a VBA code as below but it says that "Unable to set the formula array property of the range class" for the second formula. The first one works just fine. Can anyone please check & let me know what have I done wrong

This one works
VBA Code:
ws.Range("AC2").FormulaArray = "=IFERROR(INDEX(fri_dpi_labtest_date,MATCH(1,($A2=fri_dpi_labtest_po)*(""FRI 2""=fri_dpi_labtest_category),0)),"""")"
ws.Range("AC2:AC2000").FillDown

But this does not
VBA Code:
ws.Range("AC2").FormulaArray = "=IFERROR(IF(AB2=""Not Applicable"",""Not Applicable"",IF(INDEX(fri_dpi_labtest_quantity,MATCH(1,($A2=fri_dpi_labtest_po)*(""FRI 1""=fri_dpi_labtest_category),0))<L2*98%,INDEX(fri_dpi_labtest_date,MATCH(1,($A2=fri_dpi_labtest_po)*(""FRI 2""=fri_dpi_labtest_category),0)),""Not Applicable"")),"""")"
ws.Range("AC2:AC2000").FillDown

Regards,

Humayun
 
Ah OK, I was talking about the length of the resulting formula, which won't have doubled quotes in it.
 
Upvote 0

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Ah OK, I was talking about the length of the resulting formula, which won't have doubled quotes in it.
Yes

by the way If I enter the formula directly into the cell then it seems to be working just fine even though it has over 255 characters
so the restriction of entering a formula with over 255 characters is with VBA only... Am I correct ??

This is for my knowledge
 
Upvote 0

Forum statistics

Threads
1,224,748
Messages
6,180,721
Members
452,995
Latest member
isldboy

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