Solved

Function Vlookup not working

Posted on 2013-11-14
4
303 Views
Last Modified: 2013-11-16
Hi Guys, because of the Vlookup limit of 256 characters, I have had to create a Function which creates my own Vlookup, but its not working in Range ("S5") and thus getting a VALUE#.  Code is below.



Function MyVlookup(Lval As Range, c As Range, oset As Long) As Variant
Dim cl As Range
For Each cl In c.Columns(1).Cells
    If UCase(Lval) = UCase(cl) Then
        MyVlookup = cl.Offset(, oset - 1)
        Exit Function
    End If
    Next
End Function
DummyRec5.xlsx
0
Comment
Question by:Justincut
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 17

Expert Comment

by:andrewssd3
ID: 39647367
The immediate issue is that you have kept the fourth parameter to VLOOKUP in your function call, and have not defined it in your function. So either change your function to
Function MyVlookup(Lval As Range, c As Range, oset As Long, approx As Boolean) As Variant

Open in new window

or remove the final ',FALSE' from your function call.
0
 
LVL 17

Expert Comment

by:andrewssd3
ID: 39647378
It's also worth noting that the sheet is very slow to calculate - this seems largely to be because you have lots of VLOOKUPs to the 'Mapping' range which is in an external workbook, and for currencies, also external.  You will speed thing up a lot if you bring this static data inline to this workbook - external VLOOKUPs are nearly always a performance nightmare. If you want to keep the independence of the external data, you can always copy and paste link the data into this workbook.  That way it will update when the external data changes, but you VLOOKUPs will be local.
0
 

Author Comment

by:Justincut
ID: 39647463
Ok, it works. This is a Excel Rec I roll every day and date and do a Vlookup on the Previous day's spreadsheet. For the Vlookup, to work, do I have to  install the Function on the Previous days spreadsheet too?
0
 
LVL 17

Accepted Solution

by:
andrewssd3 earned 500 total points
ID: 39647527
No you only need it on the sheet that is doing the vlookup, unless the data you are looking up is dependent on a similar loookup in yesterday's sheet, etc...

Once you have the function in a workbook, it will be copied with it if you do your roll-over by taking a copy of today's sheet.  Note that you will need to save in a macro-enabled format (eg .xlsm) to get the macro to persist.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question