?
Solved

Function Vlookup not working

Posted on 2013-11-14
4
Medium Priority
?
313 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 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

765 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