📜  excel "vba" 匹配最后一个值 - VBA 代码示例

📅  最后修改于: 2022-03-11 14:51:53.187000             🧑  作者: Mango

代码示例2
'This is a code for a function that finds the last occurrence of a lookup value and returns the corresponding value from the specified column
Function LastItemLookup(Lookupvalue As String, LookupRange As Range, ColumnNumber As Integer)
  Dim i As Long
  For i = LookupRange.Columns(1).Cells.Count To 1 Step -1
    If Lookupvalue = LookupRange.Cells(i, 1) Then
      LastItemLookup = LookupRange.Cells(i, ColumnNumber)
      Exit Function
    End If
  Next i
End Function