【问题标题】:Converting Excel INDEX, MATCH, VBLOOKUP To VBA将 Excel INDEX、MATCH、VBLOOKUP 转换为 VBA
【发布时间】:2019-09-06 20:39:46
【问题描述】:

我有以下excel公式

{=INDEX(config!H2:H20,
MATCH(1,
(F2=config!F2:F20)*(VLOOKUP(D2,config!C2:D20,2,FALSE)=config!G2:G20),0))}

在 VBA 中如何编写具有多个条件的内容?这可以使用 VBA 吗?

【问题讨论】:

标签: excel vba excel-formula


【解决方案1】:

你可以这样做:

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-20
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多