Error 1004

Ramux

New Member
Joined
Aug 20, 2016
Messages
2
Hi All

Im creating a macro which inserts formulas and then autofill the column to last the last row. All formulas works except this one:

Range("J2").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[28]="""",IF(RC[-1]=""Complete"",RC[-3]+IFERROR(VLOOKUP(CONCATENATE(RC[-2],""-"",RC[-5],""-"",,RC[-4]),MasterData!C[-9]:C[-4],6,FALSE),""""),IF(RC[1]="""","""",IF(RC[-3]="""","""",IF(IFERROR(VLOOKUP(C[-6],'Priority Sheet'!C[-9]:C[-6],3,FALSE),0)>0,VLOOKUP(C[-6],'Priority Sheet'!C[-9]:C[-6],3,FALSE),RC[-3]+IFERROR(VLOOKUP(CONCATENATE(RC[-2],""-"",RC[-5],""-"",,MasterData!C1:C6,6,FALSE),""""))))),RC[28])"
Selection.AutoFill Destination:=Range("J2:J" & lastRow)

This would give the 1004 error: "Application-defined or Object-defined error"

Can anyone help med understand why it dosent work?

Thanks in advance!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I haven't looked carefully at your formula so I may be missing some error in it, but assuming its correct it may be that it has too many characters and exceeds an allowed limit for passing a string. My memory is fuzzy here, but that limit may be 255 (or 256?). Try breaking the formula string in half (to two strings) like:

sForm1 = "first half of formula (starting with "= ...)"
sForm2 = "second half"
ActiveCell.FormulaR1C1 =sForm1 & sForm2
 
Upvote 0
I haven't looked carefully at your formula so I may be missing some error in it, but assuming its correct it may be that it has too many characters and exceeds an allowed limit for passing a string. My memory is fuzzy here, but that limit may be 255 (or 256?). Try breaking the formula string in half (to two strings) like:

sForm1 = "first half of formula (starting with "= ...)"
sForm2 = "second half"
ActiveCell.FormulaR1C1 =sForm1 & sForm2

I tried to do this:

sForm1 = "=IF(RC[28]="""",IF(RC[-1]=""Complete"",RC[-3]+IFERROR(VLOOKUP(CONCATENATE(RC[-2],""-"",RC[-5],""-"",,RC[-4]),MasterData!C[-9]:C[-4],6,FALSE),""""),"

sForm2 = "IF(RC[1]="""","""",IF(RC[-3]="""","""",IF(IFERROR(VLOOKUP(C[-6],'Priority Sheet'!C[-9]:C[-6],3,FALSE),0)>0,VLOOKUP(C[-6],'Priority Sheet'!C[-9]:C[-6],3,FALSE),RC[-3]+"

sForm3 = "IFERROR(VLOOKUP(CONCATENATE(RC[-2],""-"",RC[-5],""-"",,MasterData!C1:C6,6,FALSE),""""))))),RC[28])"


Range("J2").Select
ActiveCell.FormulaR1C1 = sForm1 & sForm2 & sForm3
Selection.AutoFill Destination:=Range("J2:J" & lastRow)

Im still getting the same error :(
 
Upvote 0
Have you tested your formula by manually entering it in a worksheet?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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