excel vba last row excel “vba” match last value

The solution for “excel vba last row excel “vba” match last value” can be found here. The following code will assist you in solving the problem.

Dim rRange As Range
Dim rDuplicate As Range

Set rRange = ActiveSheet.UsedRange
lFirstRow = rRange.Row
lLastRow = rRange.Rows.Count + rRange.Row – 1
lFirstColumn = rRange.Column
lLastColumn = rRange.Columns.Count + rRange.Column – 1
‘ New reference to current range (can be resized / moved)
Set rDuplicate = Range(Cells(lFirstRow, lFirstColumn), _
Cells(lLastRow, lLastColumn))’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

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

Similar Posts