VLOOKUP 宏问题

时间:2021-01-31 10:22:11

标签: excel vba vlookup

我正在尝试使用 VBA 宏自动生成我经常执行的报告。下面的代码是子函数的一部分,我无法获得 Vlookup 公式的结果,如果你们能提供帮助,不胜感激。我在这里尝试了很多选项,但无法检索数据。仅供参考,我是 VBA 的新手。

wsReport1.Activate 'This is the source file from which the data is looked up from. The no of rows change on a day to day basis
Dim rc1 As Long
rc1 = Cells(Rows.Count, "AB").End(xlUp).Row
Dim rng1 As Range
Set rng1 = wsReport1.Range("B1:AB" & rc1) 'B1 to AB columns are standard and do not change for this range of data**

wsVLD.Activate 'This is the worksheet in which the final report is to be prepared in
Dim lrow2 As Long
lrow2 = Cells(Rows.Count, 1).End(xlUp).Row
Range("AJ2").Activate
ActiveCell.FormulaR1C1 = "=VLOOKUP(AI,[VLD_Macro.xlsm]Item_DATA!rng1,27,0)" 'AI column is a concatenate available in the Reports1 sheet in B1 column
ActiveCell.Copy _
Destination:=Range(ActiveCell, Cells(lrow2, ActiveCell.Column))
Application.CutCopyMode = False

仅供参考,以下是原始VLOOKUP路径

"=VLOOKUP(RC[-1],[VLD_Macro.xlsm]Item_DATA!R2C2:R44626C28,27,0)"

0 个答案:

没有答案