How to use “This Row” in VBA VLOOKUP?

强颜欢笑 提交于 2019-12-18 09:53:32

问题


I am trying to modify a Vlookup function so that it uses "this row" functionality. For example I have a macro that places in Column B the Following formula:

=VLOOKUP(I1253,treatlookup,11,FALSE)

This works well, however during the macro, I need to have it switch over to another formula:

=VLOOKUP(I1253,Itemlookup,22,FALSE)

Of course the data varies everytime so I can not just have that formula put in at a specific cell. So what I would like the formula to state is

= Vlookup(I"CurrentRow", ItemLookup, 22,False)

I can then use an if statement to determine which of the two formulas to use.

thanks in Advance Using Excel 2010.


回答1:


Use R1C1 style:

Activecell.FormulaR1C1 = "=VLOOKUP(RC9, ItemLookup, 22, false)"


来源:https://stackoverflow.com/questions/21689844/how-to-use-this-row-in-vba-vlookup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!