我對 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?
uj5u.com熱心網友回復:
這是你正在嘗試的嗎?
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
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/387217.html
