我有以下excel公式
{=INDEX(config!H2:H20,
MATCH(1,
(F2=config!F2:F20)*(VLOOKUP(D2,config!C2:D20,2,FALSE)=config!G2:G20),0))}
在VBA中,我将如何编写具有多个条件的内容?使用VBA可以做到吗?
答案 0 :(得分:3)
您可以执行以下操作:
Const FRM = "INDEX(config!H2:H20,MATCH(1,(F<#>=config!F2:F20)*" & _
"(VLOOKUP(D<#>,config!C2:D20,2,FALSE)=config!G2:G20),0))"
Dim res, sht as WorkSheet, rw as Long
Set sht = activesheet
rw = 2
res = sht.Evaluate(Replace(FRM, "<#>", rw)) 'use Evaluate in the context of the correct sheet
' (parent of D2, F2 in this case)