The following formula works great when I directly add it in excel, but when I add it to VBA I get a Run Time error: Application-defined or object-defined error.
This is the Formula I am inserting into the macro:
ActiveCell.FormulaR1C1 = "=VLOOKUP([[#This Row],[MATERIAL]],material!A$3:D$114,3)"
What am I doing wrong?
TableName = ActiveSheet.Previous.Name & "_Spider"
Range(TableName & "[RAWMATERIAL LENGTH]").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP([[#This Row],[MATERIAL]],material!A$3:D$114,3)"
[[#This Row],[MATERIAL]]is incorrect. The macro recorder should provide a suitable R1C1 formula to work with.Debug.Printto output the formula to the Immediate pane in the VBE, and check it's what you're expecting. Copy/paste from there to the worksheet and check it's accepted. As @SamWard notes, your formula format looks wrong.