excel - Vlookup varying column index number -
i trying change column index number of vlookup showing colnum-14
me @ cell looking at.
is there missed out? aware of match/index
formula, have use vlookup
.
my code:
dim colnum integer colnum = 15 16 sheets("sheet1").cells(8, colnum + 1).formula = "=iferror(vlookup(" & sheets("sheet1").cells(8, 3).address(false, true) & ",'sheet2'!" & range(cells(3, 2), cells(20, 10)).address & "," & "colnum-14" & ",false), ""na"")" next colnum
you embedding string "colnum-14" rather variable colnum
lookup column. try
sheets("sheet1").cells(8, colnum + 1).formula = "=iferror(vlookup(" & sheets("sheet1").cells(8, 3).address(false, true) & ",'sheet2'!" & range(cells(3, 2), cells(20, 10)).address & "," & colnum & ",false), ""na"")"