I need to use to lookup columns in from another sheet and return in a single cell VBA. My Data in Sheet1 is,
P.No. REV Qty
2918 01 50
2918 02 44
2919 01 72
In Sheet2, It should return the Qty
, by looking both the P.No.
and REV
columns. Kindly help me on this.
My code to lookup one column is below. In this I need to lookup two columns.
Function SingleCellExtractInward(lookupvalue As String, lookuprange As Range, ColumnNumber As Integer)
Dim i As Double
Dim Result1 As String
Dim Result2 As String
If Result2 = Empty Then
Result2 = "no recent inward"
SingleCellExtractInward = Result2
End If
For i = 1 To lookuprange.Columns(1).Cells.Count
If lookuprange.Cells(i, 1) = lookupvalue Then
Result1 = Result1 & " " & lookuprange.Cells(i, ColumnNumber) & ","
SingleCellExtractInward = Left(Result1, Len(Result1) - 1)
End If
Next i
End Function