Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Using Built in Functions in VBA Code

Hi I need some assistance.
Can somebody show my how to use say a vlookup function in my vba code
, as opposed to using it on a worksheet. I've done this before but
can't remember how

Something to do with application object ?

Thanks in anticipation

Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using Built in Functions in VBA Code

I find leaving out the WorksheetFunction portion works better for me. Also,
when a #N/A would be returned if used in the worksheet (no find), if you
just use Application, you can test the return value with iserror. If you
use WorksheetFunction as a qualifier, you have to use Error trapping since
it raises a trappable error.

Dim Res As Variant
Res = _
Application.VLookup(123,Range("A1:B10"),2,False)
if iserror(res) then
msgbox "Not found"
else
msgbox "Valure returned is " & res
End if

Regards,
Tom Ogilvy


"Chip Pearson" wrote in message
...
Chris,

Try something like

Dim Res As Variant
Res =
Application.WorksheetFunction.VLookup(123,Range("A 1:B10"),2,False)


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




"Chris Parker" wrote in message
om...
Hi I need some assistance.
Can somebody show my how to use say a vlookup function in my vba

code
, as opposed to using it on a worksheet. I've done this before

but
can't remember how

Something to do with application object ?

Thanks in anticipation

Chris





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
New Built in Functions 2007 Pepper Excel Worksheet Functions 6 October 19th 09 02:16 PM
Viewing Built-in Code barry New Users to Excel 4 November 19th 06 11:14 PM
language of built-in functions sylvie Excel Discussion (Misc queries) 1 November 17th 06 11:23 PM
Can I do this with built in functions? Conan Kelly Excel Worksheet Functions 3 December 6th 05 08:52 PM
How do I use Excel Built-In Functions in Code? Steve Haack Excel Worksheet Functions 7 April 26th 05 09:55 PM


All times are GMT +1. The time now is 03:46 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"