VLOOKUP() Return 第一个非空值或非 0 值
VLOOKUP() Return 1st Non Null Or Non 0 Value
我正在使用 VLOOKUP()
到 return 值,但遇到第一个值可能是 NULL
或 0
的问题
如何使用此函数(或类似函数)来 return 第一个 NON Null 或 0 值?
Application.WorksheetFunction.VLookup(filterCon, Sheets("Ace Up Sleeve").Range("A:P"), 11, False)
我将使用 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
我正在使用 VLOOKUP()
到 return 值,但遇到第一个值可能是 NULL
或 0
如何使用此函数(或类似函数)来 return 第一个 NON Null 或 0 值?
Application.WorksheetFunction.VLookup(filterCon, Sheets("Ace Up Sleeve").Range("A:P"), 11, False)
我将使用 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