[英]Pull data based from another sheet based on a cell value
我对 VBA 很陌生。 我有一个工作表“测试”和另一个工作表“源”(数据/值的来源)。 我需要根据工作表“测试”单元格 B2 上的值从“源”工作表中提取所有类别的值
测试表:
源表
我需要发生的事情取决于我在测试表上的单元格 B2 上输入的值,当我单击检索按钮时,将填写其他值。
Sub Retrieve()
Sheets("Test").Range("B1").Formula = "=VLOOKUP(B2,Source!$A:$E,1,0)"
Sheets("Test").Range("B3").Formula = "=VLOOKUP(B13,Source!$A:$I,3,0)"
Sheets("Test").Range("B4").Formula = "=VLOOKUP(B13,Source!$A:$I,4,0)"
Sheets("Test").Range("B5").Formula = "=VLOOKUP(B13,Source!$A:$I,5,0)"
End Sub
如何在上述 Vlookup 公式中放置 Iferror?
这是你正在尝试的吗?
With Sheets("Test")
.Range("B1").Formula = "=IFERROR(INDEX(Source!$A:$A,MATCH($B$2,Source!$B:$B,0),1),"""")"
.Range("B3").Formula = "=IFERROR(VLOOKUP($B$2,Source!$B:$E,2,0),"""")"
.Range("B4").Formula = "=IFERROR(VLOOKUP($B$2,Source!$B:$E,3,0),"""")"
.Range("B5").Formula = "=IFERROR(VLOOKUP($B$2,Source!$B:$E,4,0),"""")"
End With
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.