Solved

Function Vlookup not working

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now