+ Reply to Thread
Results 1 to 3 of 3

Error While Entering Vlookup Formula through Macro/VBA Code

  1. #1
    Registered User
    Join Date
    12-10-2012
    Location
    Canada
    MS-Off Ver
    Microsoft Excel: Mac 2011 & Microsoft Excel 2010
    Posts
    13

    Error While Entering Vlookup Formula through Macro/VBA Code

    Hi,
    I am writing a macro to enter a VLookup formula in a cell and autofill down to the last row. The code that I used to enter the Vlookup formula is as below:

    Please Login or Register  to view this content.
    When I execute the macro it gives me an error as below:

    Run-time error '1004' - Method 'Range' of object'_Global' failed

    I'll appreciate if someone can help me in resolving this error

    I don't know if this can be a reason for the error but the first row with cell location "Range(0,-2)" has no value. There are some other rows in the data that also have no value.

    Any help would be highly appreciated.
    Thanks... Murtaza

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Error While Entering Vlookup Formula through Macro/VBA Code

    Try this. You wouldn't need the autofill part.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: Error While Entering Vlookup Formula through Macro/VBA Code

    By doing what your first line is doing, you are actually directly inputting results of the VLookup formula into the cell, instead of inputting the formula into the cell. Even if the Vlookup succeeded, your autofill would fail.

    Try:

    Please Login or Register  to view this content.
    多么想要告诉你 我好喜欢你

+ 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. [SOLVED] Error when Entering a formula in macro
    By Davidp06 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2013, 04:38 PM
  2. Error entering formula into cell through macro
    By leafs4life22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2013, 10:18 AM
  3. [SOLVED] #Value error on entering a formula using VBA
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2013, 09:03 AM
  4. #NAME Error when entering formula
    By flyhigh515 in forum Excel General
    Replies: 6
    Last Post: 11-24-2008, 03:27 PM
  5. [SOLVED] Error when entering a formula
    By ken4capitola in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-23-2005, 04:25 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