Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Vlook accuracy

Hi...

I need a vlookup formula/code that will return an EXACT
value or an error message telling the user that the number
they've enetered doesn't exist...

Help in any form welcome!

GC
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Vlook accuracy

VLOOKUP does return an errorif an excat value is sought
but doesn't exist - just be sure that the Range_Lookup
value is set to False

In a worksheet you'd need to use an IF statement
eg
=IF(ISNA(VLOOKUP(E7,K6:L80,2,FALSE)),"NO MATCH",VLOOKUP
(E7,K6:L80,2,FALSE))

This return the 2 column in the table if there's a match,
otherwise returns the message.

In VBA, use "Application.WorksheetFunction.VLookup"

- but do it in a function where you can trap the error
eg

Sub LookupTest()

MsgBox GetValue(Range("E7"), Range("K4:L800"), 2)

End Sub

Function GetValue(Target As String, _
table As Range, _
Col As Long) As Variant
Dim result As Variant
On Error Resume Next
result = _
Application.WorksheetFunction.VLookup(Target, table,
Col, False)
If Err.Number < 0 Then
Err.Clear
result = "No Match"
End If
GetValue = result
On Error GoTo 0
End Function

Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hi...

I need a vlookup formula/code that will return an EXACT
value or an error message telling the user that the

number
they've enetered doesn't exist...

Help in any form welcome!

GC
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Vlook accuracy

Hi

Use vlookup(lookup value, table array, index number, 0)

The zero returns a false value which means it has to be an
exact match.

Ed


-----Original Message-----
Hi...

I need a vlookup formula/code that will return an EXACT
value or an error message telling the user that the

number
they've enetered doesn't exist...

Help in any form welcome!

GC
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Vlook accuracy

Gordon,

To ensure an exact match in a VLOOKUP, set the last argument to FALSE.
E.g.,

=VLOOKUP(123,A1:B10,2,FALSE)

To display an error message if not found, use something like

=IF(ISERROR(VLOOKUP(123,A1:B10,2,FALSE)),"Error",V LOOKUP(123,A1:B10,2,FALSE)
)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Gordon Cartwright" wrote in message
...
Hi...

I need a vlookup formula/code that will return an EXACT
value or an error message telling the user that the number
they've enetered doesn't exist...

Help in any form welcome!

GC



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accuracy Ad Pronk Excel Discussion (Misc queries) 7 December 5th 09 10:06 AM
VLOOK-pivot table expanding want to update vlook automatically CrimsonPlague29 Excel Worksheet Functions 0 August 8th 07 09:44 PM
VLOOK-pivot table expanding want to update vlook automatically CrimsonPlague29 Excel Worksheet Functions 0 August 8th 07 09:44 PM
CHecking accuracy schlempyasst Excel Discussion (Misc queries) 0 October 13th 05 08:15 PM
Accuracy Vyyk Excel Programming 1 September 17th 03 01:07 PM


All times are GMT +1. The time now is 01:30 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"