+ Reply to Thread
Results 1 to 14 of 14

VBA Vlookup Problem

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2007
    Posts
    7

    VBA Vlookup Problem

    I use the following code for a vlookup in my VBA Macro:
        Range("F2").Select
        ActiveCell.FormulaR1C1 = _
            "=IF(ISNA(VLOOKUP(RC[1], Lookup!A:A,1,FALSE)), ""Not Found"", ""Found"")"
        Selection.AutoFill Destination:=Range("F2:F65000")
    When this is executed in Excel, the following results show (attached picture) incorrectly. The vlookup isn't calculating?!

    But then outside of the macro, when I click in the formula bar and press 'enter', it calculates it to a different result. Why isn't it calculating correctly with this code?

    I'd appreciate any help, guidance, or direction someone can offer.

    Thanks
    Attached Images Attached Images
    Last edited by ahwestrich; 08-13-2007 at 04:36 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    HI

    Is your calculation turned to automatic?


    rylo

  3. #3
    Registered User
    Join Date
    08-13-2007
    Posts
    7
    Yeah, the calculations are set to that.

  4. #4
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Can't see why, but the only thing I can think of is that it is getting hooked up on the R1C1 format

    Try

    Range("F2").Formula = "=IF(ISNA(VLOOKUP(G2,Lookup!A:A,1,FALSE)),""Not Found"",""Found"")"
      Range("F2").AutoFill Destination:=Range("F2:F65000")
    Also, do you really want it to go down that far? Will take up a lot of memory.....


    rylo

  5. #5
    Registered User
    Join Date
    08-13-2007
    Posts
    7
    i just tried that and it did not work either

    You're right about the memory...this is just a test to make sure I can get this macro to work as planned.

    Unfortunately this stumbling block has hindered my progress

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    What reference style do you have in your sheet? R1C1, or non R1C1?


    rylo

+ 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