Function MyVlookup(Lval As Range, c As Range, oset As Long) As Variant
Dim cl As Range
Set mycolrange = Range(Cells(1, c.Columns(1)), Cells(Rows.Count, c.Columns(1)).End(xlUp))
For Each cl In mycolrange
If UCase(Lval) = UCase(cl) Then
MyVlookup = cl.Offset(, oset - 1)
Exit Function
End If
Next
End Function
Function MyVlookup(Lval As Range, c As Range, oset As Long) As Variant
Dim cl As Range
Set mycolrange = Range(Cells(1, c.Column), Cells(Rows.Count, c.Column).End(xlUp))
For Each cl In mycolrange
If UCase(Lval) = UCase(cl) Then
MyVlookup = cl.Offset(, oset - 1)
Exit Function
End If
Next
End Function
to use the column of the rangeFunction MyVlookup(Lval As Variant, c As Range, oset As Long) As Variant
Dim cl As Range, MyColRange As Range
Dim v As Variant
On Error Resume Next
v = Application.VLookup(Lval, c, oset, False)
On Error GoTo 0
If IsError(v) Then
With c.Worksheet
Set MyColRange = Range(c.Cells(1, 1), .Cells(.Rows.Count, c.Column).End(xlUp))
End With
For Each cl In MyColRange
If UCase(Lval) = UCase(cl) Then
v = cl.Offset(, oset - 1)
Exit For
End If
Next
End If
MyVlookup = v
End Function
=INDEX(A1:A10;MATCH(TRUE;INDEX(B1:B10=D1;0);0))
As Index doesn't have the 256 chars limitation but Match has you have to use Index twice in the formula. The other advantage of using Index and Match is that you don't have to sort the range where you lookup the value.
Dim cl As Range
Dim count =1
For Each cl In c.Columns(1).Cells
if count < 1000
If UCase(Lval) = UCase(cl) Then
MyVlookup = cl.Offset(, oset - 1)
count = count+1
Exit Function
End If
else
Exit Function
end if
Next
End Function