LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using Built in Functions in VB Code

I like to do it this way:

Dim Pos as Variant 'could return an error
dim inValue as Variant 'string, number, what???
dim namedtable as Range

with worksheets("somesheet")
set namedtable = .range("sometablerangehere")
end with

pos = application.vlookup(invalue, namedtable, 2, false)

if iserror(pos) then
'not found
else
'found, rest of code goes here
end if

This assumes that invalue and namedtable are variables in your code.



Jim Conrady wrote:

I apologize if this is some trivial question that has an easy answer, but I
have been through help and 2 different Excel VB books and cannot get this to
work.

Problem: In a VB Function, I would like to do the following:

Pos = VLookup(InValue, NamedTable, 2, FALSE)

The debugger won't let me use VLookup. I also tried Average, etc., and the
debugger pops on whatever built-in function I use.

Is there a flag I can set, or a technique I need to use to make this work?

I really know excel, but am a novice at VB. I can get around it nesting
vlookups in the spreadsheet, but it is really ugly. Being able to do this
would enable me to clean up my code a bunch. I would welcome feedback.

Regards,

Jim

--------------
Jim Conrady


--

Dave Peterson


 
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
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
Viewing built-in functions Jim[_36_] Excel Programming 2 December 29th 03 12:59 PM
Using Built in Functions in VBA Code Chris Parker Excel Programming 1 July 16th 03 05:42 PM


All times are GMT +1. The time now is 07:20 AM.

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"