![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Hi all.
I am using the VLookup function in VBA and can not get it to work. Please help... Ex.
The range A1:B5 is named: E_List How do I incorporate this named range into my VLookup function? Here is my current code. I keep getting an error.
E_Address should return "Are" Another question: Can I also get this function to return the row number? In this example RowNum would equal 2. Thanks, Tom |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Calgary, Alberta Canada
Posts: 2,065
|
The following UDF (User Defined Function) works. I used named ranges Code and E_List. Use Function as =LookupA(CODE, E_List) Function LookupA(CODE, E_List) If CODE <> "" Then With Application.WorksheetFunction LookupA = .VLookup(CODE, E_List, 2, False) End With Else LookupA = "" End If End Function |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
Thanks Dave,
Works perfectly... I was about to give up on this one and just code the formula to a worksheet and use it from there... Thanks Again! Tom |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|