LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default using VLookUp in a VBA program

Thanks to this thread I solved as well my problem with vlookup,
already started to bang my head against the wall.

so definitely "Application.vlookup" is the solution.

Problem: checking a list of unique values, to determine if a "ne
value" to be added is really "new".
If the value exists in the list I check, then the information to th
right of the value is a "String"

Solution:

Code
-------------------

MyResult = Application.VLookup(MyValue, Range(MyRange), 2, False)

Select Case VarType(MyResult)

Case vbError
Select Case MyResult
Case CVErr(2042) '"Data not found"
'This is the desired condition in my solution

Case Else
'Another error occured that I dont know about
MsgBox CStr(MyResult), , "vlookup"
Exit Sub
End Select

Case vbString ' The Value was found, meaning my value is not unique.
Exit Sub

Case Else 'another vartype was returned that I did not expect
MsgBox VarType(Result), , "vlookup"
Exit Sub

End Select

-------------------


--
Message posted from http://www.ExcelForum.com

 
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
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
My Program SM Charts and Charting in Excel 1 October 21st 05 09:48 PM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM
How to program a key, say F4? Jonathan Lee Excel Programming 2 October 14th 03 09:42 PM
run program Van daal Excel Programming 1 September 12th 03 04:50 PM


All times are GMT +1. The time now is 07:24 PM.

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

About Us

"It's about Microsoft Excel"