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.
[/CODE]
Any help is appreciated
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)"
Any help is appreciated