#1004 Application-Defined Error

vatrobo1

New Member
Joined
Mar 19, 2019
Messages
2
Hi,


I am facing #1004 Application-Defined Error issue when try to apply below formula with VBA. The actual formula is :


=IFERROR(
IF(INDEX('Source data'!$D$4:$ES$40003,MATCH($G5,'Source data'!$EF$4:$EF$40003,0),MATCH(H$3,'Source data'!$D$4:$ES$4,0))="N",
INDEX('Source data'!$D$4:$ES$40003,MATCH($G5,'Source data'!$EF$4:$EF$40003,0),MATCH(H$2,'Source data'!$D$4:$ES$4,0)),
INDEX('Source data'!$D$4:$ES$40003,MATCH($G5,'Source data'!$EF$4:$EF$40003,0),MATCH(H$2,'Source data'!$D$4:$ES$4,0))/INDEX('Source data'!$D$4:$ES$40003,MATCH($G5,'Source data'!$EF$4:$EF$40003,0),MATCH(H$1,'Source data'!$D$4:$ES$4,0))
),0)


After recording the formula with macro , I am getting the following :


ActiveCell.FormulaR1C1 = _
"=IFERROR(" & Chr(10) & "IF(INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R3C,'Source data'!R4C4:R4C149,0))=""N""," & Chr(10) & "INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R2C,'Source data'!R4C4:R4C149,0))," & Chr(10) & "INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R2C,'Source data'!" & _
"149,0))/INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R1C,'Source data'!R4C4:R4C149,0))" & Chr(10) & "),0)"


If I try to run the macro with above formula, I am getting #1004 Application-Defined or Object-Defined Error
Can some one please help me to fix this?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi & welcome to MrExcel
When recording large formula like that the recorder will sometimes lose part of the formula.
Try
Code:
   Selection.FormulaR1C1 = "=IFERROR(IF(INDEX('Source data'!R4C4:R40003C149,MATCH(R[-22]C7,'Source data'!R4C136:R40003C136,0),MATCH(R3C[-4],'Source data'!R4C4:R4C149,0))=""N""," & _
      "INDEX('Source data'!R4C4:R40003C149,MATCH(R[-22]C7,'Source data'!R4C136:R40003C136,0),MATCH(R2C[-4],'Source data'!R4C4:R4C149,0)),INDEX('Source data'!R4C4:R40003C149," & _
      "MATCH(R[-22]C7,'Source data'!R4C136:R40003C136,0),MATCH(R2C[-4],'Source data'!R4C4:R4C149,0))/INDEX('Source data'!R4C4:R40003C149," & _
      "MATCH(R[-22]C7,'Source data'!R4C136:R40003C136,0),MATCH(R1C[-4],'Source data'!R4C4:R4C149,0))),0)"
 
Upvote 0
Hey Fluff,

Thanks much for the response and quick solution. Based on your input , I corrected the macro generated incorrect formula.

After recording the formula with macro , I am getting the following :

ActiveCell.FormulaR1C1 = _
"=IFERROR(" & Chr(10) & "IF(INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R3C,'Source data'!R4C4:R4C149,0))=""N""," & Chr(10) & "INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R2C,'Source data'!R4C4:R4C149,0))," & Chr(10) & "INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R2C,'Source data'!" & _
"149,0))/INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R1C,'Source data'!R4C4:R4C149,0))" & Chr(10) & "),0)"

Now I corrected it to :

ActiveCell.FormulaR1C1 = _
"=IFERROR(" & Chr(10) & "IF(INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R3C,'Source data'!R4C4:R4C149,0))=""N""," & Chr(10) & "INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R2C,'Source data'!R4C4:R4C149,0))," & Chr(10) & "INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R2C,'Source data'!" & _
"R4C4:R4C149,0))/INDEX('Source data'!R4C4:R40003C149,MATCH(RC7,'Source data'!R4C136:R40003C136,0),MATCH(R1C,'Source data'!R4C4:R4C149,0))" & Chr(10) & "),0)"
ActiveSheet.Range("H5").Select


It is working perfectly now. Thanks again :)
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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