FormulaR1C1 + Error 1004

itsme0481

New Member
Joined
Feb 3, 2021
Messages
2
Office Version
  1. 365
Hi,
I have written some code that looks for column headings to locate the columns of data required in my formula, thus returning a column number.
So logically the best method of creating my formula in the cell is to use the FormulaR1C1 function in vba, however I have been unsuccessful in getting the formula working.

I have had numerous errors appear and have been able to overcome them - however I now cant get past the run-time error '1004' Application-defined or object-defined error.
I struggle to understand why it would be an object error due to all the ranges being defined in R1C1 notation (After failing to be-able to use ranges defined in VBA and plugging it straight into the formula due to mis-match errors) and for the application error - Ive had this formula working when using the .Formula function - so I know it works.. It's just when .FormulaR1C1 is used the code fails.

In my attempt to trouble shoot - I have taken each term within the formula and inserted it into different cells and all terms using R1C1 work correctly, again its just when this is inputted into the formula it fails.

The formula I am using is a Forecast/Index/Match expression to use linear interpolation in another workbook for the (((RC" & Xflcol & ")* -1) - RC" & BGfcol & ") value against the table in the workbook the code is in "Mapping_Tool.xlsm" (a bonus point will be given if someone can incorporate ThisWorkbook instead of the file name - I have been unsuccessful in doing so)

In order for this section of code to work within the project Im creating I need this to work in R1C1.

VBA Code:
Set FirstBumpFL = .Cells(2, Lcol + 7)
FirstBumpFL.FormulaR1C1 = "= IFERROR(FORECAST((((RC" & Xflcol & ")* -1) - RC" & BGfcol & "),INDEX('[Mapping_Tool.xlsm]Import'!R5C14:R238C14,MATCH((((RC" & Xflcol & ")* -1) - RC" & BGfcol & "),'[Mapping_Tool.xlsm]Import'!R5C13:R238C13,1)):INDEX('[Mapping_Tool.xlsm]Import'!R5C14:R238C14,MATCH((((RC" & Xflcol & ")* -1) - RC" & BGfcol & "),'[Mapping_Tool.xlsm]Import'!R5C13:R238C13,1)+1,INDEX('[Mapping_Tool.xlsm]Import'!R5C13:R238C13,MATCH((((RC" & Xflcol & ")* -1) - RC" & BGfcol & "),'[Mapping_Tool.xlsm]Import'!R5C13:R238C13,1)):INDEX('[Mapping_Tool.xlsm]Import'!R5C13:R238C13,MATCH((((RC" & Xflcol & ")* -1) - RC" & BGfcol & "),'[Mapping_Tool.xlsm]Import'!R5C13:R238C13,1)+1)),0)"
[/CODE]

Any help is appreciated
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
You're missing a closing parenthesis, looks like it's for the second INDEX function.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,813
Messages
6,181,109
Members
453,021
Latest member
Justyna P

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