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
Solved

Function Vlookup not working

Posted on 2013-11-14
4
297 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel Lookup - True if return at least one match 9 44
Need Help with Mapping and Toggling 3 22
SKip past fields with no data 6 15
Countdown Timer in Excel 6 14
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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