+ Reply to Thread
Results 1 to 9 of 9

For loop vlookup

  1. #1
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    For loop vlookup

    Hi,

    I'm trying to create a vlookup on multiple. It's pretty straightforward but I get a #NAME error. I'm pretty sure it has to do with my counter variable but need help on fixing it.

    Please Login or Register  to view this content.
    Thanks,
    amphinomos

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: For loop vlookup

    I think you probably need:
    "=VLOOKUP(" & x & "," & LkRange.address & ",2,0)"

  3. #3
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Re: For loop vlookup

    Thanks ragulduy. I get a #N/A error but that's probably because I've set up my ranges/counter wrong. What I would like to do is vlookup Sheet1!A1:A5 (I've changed SrcRange to A1:B5) with Sheet2!A1:B5 and put the values in Sheet1!B1:B5. As I've set it up, I'm doing a vlookup of the counter itself ?

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: For loop vlookup

    I think you would need dollar signs when you set your range.

    Set LkRange = Sheets(2).Range("$A$1:$B$5")

  5. #5
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: For loop vlookup

    Try:
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Re: For loop vlookup

    Thanks raguldy. I've modified the code but still can't get it to perform what I'd like :

    Please Login or Register  to view this content.
    If I check in Sheet1!B1 it's currently giving me this formula =VLOOKUP($A$1:$A$5,$A$1:$B$5,2,0) where I would need =VLOOKUP(Sheet1!A1,Sheet2!$A$1:$B$5,2,0).

  7. #7
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: For loop vlookup

    Hi, that is not the code I posted. You need:
    Please Login or Register  to view this content.

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: For loop vlookup

    Any reason you can't use it like this?

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-30-2013
    Location
    France
    MS-Off Ver
    2010
    Posts
    260

    Re: For loop vlookup

    Thanks guys. Ragulduy your code works fine...didn't realize it should've been so simple.
    JOHN I've also tried your code but the Address method only returns in the vlookup $A$1:$B$5 and not Sheet2!$A$1:$B$5.
    In any case many thanks !

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Vlookup loop vba
    By mzang7 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2012, 03:13 PM
  2. VBA for Do Until Loop with VLookUp
    By jack.d in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-21-2012, 02:00 AM
  3. VlookUp with Loop?
    By ezek in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-05-2012, 06:24 AM
  4. Replies: 5
    Last Post: 07-29-2009, 07:53 AM
  5. Vlookup loop
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-25-2008, 08:53 AM

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