Link to home
Start Free TrialLog in
Avatar of Steven Vermoere
Steven VermoereFlag for Belgium

asked on

Change vlookup-range in function

Hello,

I want to create a function that looks in a certain range for a certain value

The name of the range is in cell B1, de value that needs to be looked up is ie cell A1. I have several ranges: BE_UP, BE_DOWN, NL_UP, NL_DOWN. They are al defined

In cell A1 I enter the value that I'm looking for
In Cell B1, I enter the value of the range that he needs looking in

first question: is it possible to do this with the norma vlookup-formula

Second question: in the code below, I tried it, but I do not get any value
 
Function VLOOKUPGV(oRNGSearch As Range, oRNGLookup As Range, iCol As Integer, bTemp As Boolean) 

Dim sRange As String
Dim dtLookup

VLOOKUPGV = Application.WorksheetFunction.VLookup(oRNGSearch.value, Application.Range(oRNGLookup.value), iCol, True)

End Function

Open in new window


What is going wrong ?

Thank you very much
Avatar of nutsch
nutsch
Flag of United States of America image

use indirect to convert a range string to an actual range

=vlookup(a1,indirect("B1"),2,0)

Thomas
ASKER CERTIFIED SOLUTION
Avatar of nutsch
nutsch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Steven Vermoere

ASKER

Yes, this was it. Thanks