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
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
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.
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" <Norie.1u4rif_1124654732.2064@excelforum-nospam.com> wrote in
message news:Norie.1u4rif_1124654732.2064@excelforum-nospam.com...
>
> 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
>
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.
Sure is
ans = Application.VLOOKUP(val,rng,2,False)
--
HTH
RP
(remove nothere from the email address if mailing direct)
"UofMoo" <UofMoo.1u4oqb_1124651117.4341@excelforum-nospam.com> wrote in
message news:UofMoo.1u4oqb_1124651117.4341@excelforum-nospam.com...
>
> 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
>
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" <UofMoo.1u4oqb_1124651117.4341@excelforum-nospam.com> wrote in
> message news:UofMoo.1u4oqb_1124651117.4341@excelforum-nospam.com...
> >
> > 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
> >
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks