Vlookup using vba
Rather than clog your workbook with VLOOKUP functions, you can perform the same task through vba. Unlike the VLOOKUP function, there is no need to have the data in ascending order.
This example looks for the value cell $A$1 from “Sculpt” worksheet, returning the corresponding value in the 2nd column of a range in the “Range” worksheet. The value is returned in the form of function and can be retrieved from other subs.
Public Function Vlookup() As Long
Dim x As Integer
Dim strLookup As String
x = 1
strLookup = Worksheets(“Sculpt”).Range(“$A$1:$A$1″)
Do Until Worksheets(“Range”).Cells(x, 1).Value = “”
If Worksheets(“Range”).Cells(x, 1).Value = strLookup Then
Vlookup = Worksheets(“Range”).Cells(x, 2).Value
Exit Do ‘if value is found, the code stops searching
x = x + 1