Sorry for not adapting to the forum rules..now i have placed my code under the code tag
here is my query:
I am trying to use application,vlookup to extract the related data based on the user provided code number. Even though the code number is existing in the array, it is not giving the proper result. I have given my code below, any help is much appreciated.
Function test(usercode As String) As Long
'declaring an array
Dim arr As Variant
'assigning range of values to the array
arr = Worksheets(1).Range("A1").CurrentRegion
'using a vlookup formula to take the related data of the code from the array
If IsError(Application.VLookup(usercode, arr, 2, 0)) Then
test = 0
Else
test = Application.VLookup(usercode, arr, 2, 0)
End If
End Function
Bookmarks