I had this question after viewing How to add a column of to the end of columns with value from table with VBA
Rgonzo1971 was so kind helping me with the code below.
now when my data changed, (plz see attached) i could not fix the VLOOKUP thing. my financial model sometimes data is in the right side and i cannot change the order. now i am stuck. how can the VBA below be modified so that description is returned from the right column.
i would appreciate any help i can get here.
Set ShD = Sheets("Data")
intProductCol = Split(Range("dataPRODUCT").Address, "$")(1)
FirstFreeCol = ShD.Cells(1, Columns.Count).End(xlToLeft).Column + 1
Set Rng = Range(ShD.Cells(2, FirstFreeCol), ShD.Cells(ShD.Range("a" & Rows.Count).End(xlUp).Row, FirstFreeCol))
Rng.Formula = "=IFERROR(VLOOKUP(" & intProductCol & "2,'Lookup Table'!$A$1:$B$6,2,FALSE),VLOOKUP(LEFT(" & intProductCol & "2,1)&""*"",'Lookup Table'!$A$1:$B$6,2,FALSE))"
Rng.Value = Rng.Value