【发布时间】:2013-11-30 14:49:08
【问题描述】:
我正在尝试将变量添加到 vlookup 公式化函数中
下图可以运行
Cells(17, LastCol + 1).Formula = "=vlookup(" & Sheets("Sheet1").Range("C17").Address(False, False) & ",'Temp'!B:C,2,False)"
但我想做的是添加变量来替换公式中的 B:C,看起来像这样
Cells(17, LastCol + 1).Formula = "=vlookup(" & Sheets("VPC4").Range("C17").Address(False, False) & ",'Temp'!Cells(Row1,2):Cells(Row2,3),2,False)"
在哪里
Row1 = Sheets("Temp").Cells.Find(What:="test", SearchDirection:=xlUp, SearchOrder:=xlByRows).Row
Row2 = Sheets("Temp").Cells.Find(What:="test1", SearchDirection:=xlUp, SearchOrder:=xlByRows).Row
它没有按照我的预期执行,而是显示了 $name。因此,我需要将 vba 作为公式化输出,因此使用了 .formula。请指教。
【问题讨论】: