+ Reply to Thread
Results 1 to 6 of 6

VLookup in VB?

  1. #1
    Registered User
    Join Date
    08-20-2005
    Posts
    13

    VLookup in VB?

    Is there a way to access functions in a sub ?
    i'd like to use vlookup in one of my VB modules...
    thanks in advance

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Take a look at the WorksheetFunction method of the Application object.

    It let's you access most worksheet functions in VBA.

    By the way using Vlookup in VBA can sometimes be a problem, if errors are returned by the function VBA won't like it.

  3. #3
    Bob Phillips
    Guest

    Re: VLookup in VB?

    Sure is

    ans = Application.VLOOKUP(val,rng,2,False)

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "UofMoo" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Is there a way to access functions in a sub ?
    > i'd like to use vlookup in one of my VB modules...
    > thanks in advance
    >
    >
    > --
    > UofMoo
    > ------------------------------------------------------------------------
    > UofMoo's Profile:

    http://www.excelforum.com/member.php...o&userid=26485
    > View this thread: http://www.excelforum.com/showthread...hreadid=397602
    >




  4. #4
    WhytheQ
    Guest

    Re: VLookup in VB?

    or worksheetfunction.vlookup(val,rng,2,False)


    Bob Phillips wrote:
    > Sure is
    >
    > ans = Application.VLOOKUP(val,rng,2,False)
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "UofMoo" <[email protected]> wrote in
    > message news:[email protected]...
    > >
    > > Is there a way to access functions in a sub ?
    > > i'd like to use vlookup in one of my VB modules...
    > > thanks in advance
    > >
    > >
    > > --
    > > UofMoo
    > > ------------------------------------------------------------------------
    > > UofMoo's Profile:

    > http://www.excelforum.com/member.php...o&userid=26485
    > > View this thread: http://www.excelforum.com/showthread...hreadid=397602
    > >



  5. #5
    Bob Phillips
    Guest

    Re: VLookup in VB?

    Easily handled,

    ans = application.vlookup(....
    If Iserror(ans) Then
    ...

    or

    On Error
    ans = WorksheetFunction.VLookup(...
    On Error Resume Next

    If IsEmpty(ans) Then
    ...

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Norie" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Take a look at the WorksheetFunction method of the Application object.
    >
    > It let's you access most worksheet functions in VBA.
    >
    > By the way using Vlookup in VBA can sometimes be a problem, if errors
    > are returned by the function VBA won't like it.
    >
    >
    > --
    > Norie
    > ------------------------------------------------------------------------
    > Norie's Profile:

    http://www.excelforum.com/member.php...o&userid=19362
    > View this thread: http://www.excelforum.com/showthread...hreadid=397602
    >




  6. #6
    Registered User
    Join Date
    08-20-2005
    Posts
    13

    Thank you thank you

    Thanks everyone, I think i got it to work with your help!
    You're the best
    Last edited by UofMoo; 08-21-2005 at 05:43 PM. Reason: i'm great at generating Run-time Errors... doh.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1