PC Review


Reply
Thread Tools Rate Thread

Application.WorksheetFunction.VLookup (Plz Help)

 
 
Raj
Guest
Posts: n/a
 
      3rd Jul 2007
Hi,

I have been working on Excel VBA for some time now.. Actually what
i want to do is quite simple. i want to copy data from another sheet
in the same workbook checking the keyfield coloumn and i am trying to
get the values using the Application.WorksheetFunction.VLookup
like the syntax
given :"(Application.WorksheetFunction.VLookup(SearchString, MyRange,
ReturnCol, False)") but the range is not coming through properly.When
i try to check the range in the immediate window it gives me a type
mismatch error... I am fetching the range as given below "(Set MyRange
= Sheets("SheetName (2)").Range("A7:B20")").... Can anyone please help
me on this it would be great if any one in the group can...

 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Jul 2007
This works fine for me

SearchString = "abc"
ReturnCol = 2
Set MyRange = Sheets("SheetName (2)").Range("A7:B20")
x = Application.WorksheetFunction.VLookup(SearchString, MyRange, ReturnCol,
False)


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Raj" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have been working on Excel VBA for some time now.. Actually what
> i want to do is quite simple. i want to copy data from another sheet
> in the same workbook checking the keyfield coloumn and i am trying to
> get the values using the Application.WorksheetFunction.VLookup
> like the syntax
> given :"(Application.WorksheetFunction.VLookup(SearchString, MyRange,
> ReturnCol, False)") but the range is not coming through properly.When
> i try to check the range in the immediate window it gives me a type
> mismatch error... I am fetching the range as given below "(Set MyRange
> = Sheets("SheetName (2)").Range("A7:B20")").... Can anyone please help
> me on this it would be great if any one in the group can...
>



 
Reply With Quote
 
Raj
Guest
Posts: n/a
 
      3rd Jul 2007
On Jul 3, 3:25 pm, "Bob Phillips" <bob....@somewhere.com> wrote:
> This works fine for me
>
> SearchString = "abc"
> ReturnCol = 2
> Set MyRange = Sheets("SheetName (2)").Range("A7:B20")
> x = Application.WorksheetFunction.VLookup(SearchString, MyRange, ReturnCol,
> False)
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "Raj" <rajesh....@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Hi,

>
> > I have been working on Excel VBA for some time now.. Actually what
> > i want to do is quite simple. i want to copy data from another sheet
> > in the same workbook checking the keyfield coloumn and i am trying to
> > get the values using the Application.WorksheetFunction.VLookup
> > like the syntax
> > given :"(Application.WorksheetFunction.VLookup(SearchString, MyRange,
> > ReturnCol, False)") but the range is not coming through properly.When
> > i try to check the range in the immediate window it gives me a type
> > mismatch error... I am fetching the range as given below "(Set MyRange
> > = Sheets("SheetName (2)").Range("A7:B20")").... Can anyone please help
> > me on this it would be great if any one in the group can...- Hide quoted text -

>
> - Show quoted text -


Is there any version problem.. I am using Office 2000 here....


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      3rd Jul 2007
You may want to post the code you used.

I like:

dim Res as variant
dim SomeValue as variant 'or string or long???
dim myRng as range
Set MyRange = Sheets("SheetName (2)").Range("A7:B20")
somevalue = "what goes here"
res = application.vlookup(somevalue,myrange,2, false)

if iserror(res) then
msgbox "an error was returned"
else
mesgbox res
end if

Notice that I didn't use application.worksheetfunction.vlookup.


Raj wrote:
>
> On Jul 3, 3:25 pm, "Bob Phillips" <bob....@somewhere.com> wrote:
> > This works fine for me
> >
> > SearchString = "abc"
> > ReturnCol = 2
> > Set MyRange = Sheets("SheetName (2)").Range("A7:B20")
> > x = Application.WorksheetFunction.VLookup(SearchString, MyRange, ReturnCol,
> > False)
> >
> > --
> > HTH
> >
> > Bob
> >
> > (there's no email, no snail mail, but somewhere should be gmail in my addy)
> >
> > "Raj" <rajesh....@gmail.com> wrote in message
> >
> > news:(E-Mail Removed)...
> >
> >
> >
> > > Hi,

> >
> > > I have been working on Excel VBA for some time now.. Actually what
> > > i want to do is quite simple. i want to copy data from another sheet
> > > in the same workbook checking the keyfield coloumn and i am trying to
> > > get the values using the Application.WorksheetFunction.VLookup
> > > like the syntax
> > > given :"(Application.WorksheetFunction.VLookup(SearchString, MyRange,
> > > ReturnCol, False)") but the range is not coming through properly.When
> > > i try to check the range in the immediate window it gives me a type
> > > mismatch error... I am fetching the range as given below "(Set MyRange
> > > = Sheets("SheetName (2)").Range("A7:B20")").... Can anyone please help
> > > me on this it would be great if any one in the group can...- Hide quoted text -

> >
> > - Show quoted text -

>
> Is there any version problem.. I am using Office 2000 here....


--

Dave Peterson
 
Reply With Quote
 
Raj
Guest
Posts: n/a
 
      4th Jul 2007
On Jul 3, 5:18 pm, Dave Peterson <peter...@verizonXSPAM.net> wrote:
> You may want to post the code you used.
>
> I like:
>
> dim Res as variant
> dim SomeValue as variant 'or string or long???
> dim myRng as range
> Set MyRange = Sheets("SheetName (2)").Range("A7:B20")
> somevalue = "what goes here"
> res = application.vlookup(somevalue,myrange,2, false)
>
> if iserror(res) then
> msgbox "an error was returned"
> else
> mesgbox res
> end if
>
> Notice that I didn't use application.worksheetfunction.vlookup.
>
>
>
>
>
> Raj wrote:
>
> > On Jul 3, 3:25 pm, "Bob Phillips" <bob....@somewhere.com> wrote:
> > > This works fine for me

>
> > > SearchString = "abc"
> > > ReturnCol = 2
> > > Set MyRange = Sheets("SheetName (2)").Range("A7:B20")
> > > x = Application.WorksheetFunction.VLookup(SearchString, MyRange, ReturnCol,
> > > False)

>
> > > --
> > > HTH

>
> > > Bob

>
> > > (there's no email, no snail mail, but somewhere should be gmail in my addy)

>
> > > "Raj" <rajesh....@gmail.com> wrote in message

>
> > >news:(E-Mail Removed)...

>
> > > > Hi,

>
> > > > I have been working on Excel VBA for some time now.. Actually what
> > > > i want to do is quite simple. i want to copy data from another sheet
> > > > in the same workbook checking the keyfield coloumn and i am trying to
> > > > get the values using the Application.WorksheetFunction.VLookup
> > > > like the syntax
> > > > given :"(Application.WorksheetFunction.VLookup(SearchString, MyRange,
> > > > ReturnCol, False)") but the range is not coming through properly.When
> > > > i try to check the range in the immediate window it gives me a type
> > > > mismatch error... I am fetching the range as given below "(Set MyRange
> > > > = Sheets("SheetName (2)").Range("A7:B20")").... Can anyone please help
> > > > me on this it would be great if any one in the group can...- Hide quoted text -

>
> > > - Show quoted text -

>
> > Is there any version problem.. I am using Office 2000 here....

>
> --
>
> Dave Peterson- Hide quoted text -
>
> - Show quoted text -


thanks for all of yor valued time in it.......... i found out a
another way which is working fine till now by putting the formula in
the cell and then getting the value for the same as given below.....

Range(pCol & iRow).Formula = _
"=VLOOKUP(" & pKeyCol & iRow & ",'" & sSchSheet & "'!"
& _
sRange & "," & SvlookupCol & ",0)"
Range(pCol & iRow).Value = Range(pCol & iRow).Text

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use the worksheetfunction Vlookup R Tanner Microsoft Excel Programming 7 14th Aug 2008 08:34 PM
worksheetfunction.vlookup in vba pmoon7 Microsoft Excel Programming 4 25th Jan 2006 09:00 PM
Worksheetfunction.Vlookup Robert Wilcox Microsoft Excel Programming 1 14th May 2005 05:00 AM
application.worksheetfunction.vlookup JulieD Microsoft Excel Programming 5 12th Aug 2004 04:42 PM
worksheetfunction.vlookup? =?Utf-8?B?ZGV2bmV4dA==?= Microsoft Excel Programming 1 29th Oct 2003 06:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:15 PM.