【问题标题】:VLOOKUP() Return 1st Non Null Or Non 0 ValueVLOOKUP() 返回第一个非 Null 或非 0 值
【发布时间】:2017-08-14 23:30:21
【问题描述】:

我正在使用VLOOKUP() 返回值,但遇到了第一个值可能是NULL0 的问题

如何使用此函数(或类似函数)返回第一个 NON Null 或 0 值?

Application.WorksheetFunction.VLookup(filterCon, Sheets("Ace Up Sleeve").Range("A:P"), 11, False)

【问题讨论】:

  • VLOOKUP 公式只返回找到的第一个结果。例如,您必须使用不同的公式或 Find 方法。

标签: vba excel excel-formula excel-2013


【解决方案1】:

我将使用 AGGREGATE 工作表函数在工作表上完成此操作。将其带入 VBA,您可以在同一公式上使用 Application.Evaluate(...)

Dim filterCon As String, fr As Variant, lr As Long, vreturn As Variant

filterCon = "findthis"

With Worksheets("Ace Up Sleeve")
    lr = .Cells(.Rows.Count, "A").End(xlUp).Row
    fr = Application.Evaluate("aggregate(15, 6, row(1:" & lr & ")/('Ace Up Sleeve'!K1:K" & lr & "<>0), 1)")
    If Not IsError(fr) Then
        vreturn = .Cells(fr, "K").Value
        Debug.Print vreturn
    End If
End With

【讨论】:

    猜你喜欢
    • 2017-06-24
    • 2017-09-02
    • 1970-01-01
    • 2019-03-13
    • 2019-12-07
    • 1970-01-01
    • 2018-05-20
    • 1970-01-01
    • 2014-04-03
    相关资源
    最近更新 更多