Not quite sure why this keeps giving me an Application error. I'm trying to just do a VLOOKUP to another workbook, just columns A to B but I need to do it down to the final row, hence the LastPivotRow. StrFile is the file with the Table I'm looking against and PivotTable. StartCol is the first empty cell as I'm building a data table by looking up values in several PivotTables in different workbooks.
VBA Code:
Sheets(1).Activate
StartCol = Cells(2, Columns.Count).End(xlToLeft).Offset(0, 1).Count
Cells(2, StartCol + 1).Select
ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R2C[-StartCol], '[" & StrFile & "]PivotTable'!R1C1:R[PivotEndRow]C2,2,0)"