ExcelNoob11
New Member
- Joined
- Jul 17, 2018
- Messages
- 7
I have a table with 10 columns that I need to insert formulas into to the last 5 columns to return values from a lookup table.
My formula works for the first 3 columns but the last 2 for some reason the RC goes haywire and points to some wild cells.
Column 6= =IFERROR(VLOOKUP(A9,Table1,2,FALSE),"")
Column 7= =IFERROR(VLOOKUP(A9,Table1,3,FALSE),"")
Column 8= =IFERROR(VLOOKUP(A9,Table1,4,FALSE),"")
Column 9= =VLOOKUP(XFD9,Table1,5,FALSE) <-- That should Be A9 too, but instead it goes to XFD9?
Column 10= =VLOOKUP(#REF!,Table1,6,FALSE) <-- then column 10 doesn't know where to look.
Here's my code:
My formula works for the first 3 columns but the last 2 for some reason the RC goes haywire and points to some wild cells.
Column 6= =IFERROR(VLOOKUP(A9,Table1,2,FALSE),"")
Column 7= =IFERROR(VLOOKUP(A9,Table1,3,FALSE),"")
Column 8= =IFERROR(VLOOKUP(A9,Table1,4,FALSE),"")
Column 9= =VLOOKUP(XFD9,Table1,5,FALSE) <-- That should Be A9 too, but instead it goes to XFD9?
Column 10= =VLOOKUP(#REF!,Table1,6,FALSE) <-- then column 10 doesn't know where to look.
Here's my code:
Code:
LastCol = Cells(2, Columns.Count).End(xlToLeft).Column
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("F9").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-5],Table1,2,FALSE),"""")"
Range("F9", Cells(LastRow, 9)).FormulaR1C1 = Range("F9").FormulaR1C1
Range("G9").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-6],Table1,3,FALSE),"""")"
Range("G9", Cells(LastRow, 9)).FormulaR1C1 = Range("G9").FormulaR1C1
Range("H9").Select
ActiveCell.FormulaR1C1 = "=IFERROR(VLOOKUP(RC[-7],Table1,4,FALSE),"""")"
Range("H9", Cells(LastRow, 9)).FormulaR1C1 = Range("H9").FormulaR1C1
Range("I9").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-8],Table1,5,FALSE)"
Range("I9", Cells(LastRow, 9)).FormulaR1C1 = Range("I9").FormulaR1C1
Range("J9").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-9],Table1,6,FALSE)"
Range("J9", Cells(LastRow, 9)).FormulaR1C1 = Range("J9").FormulaR1C1