+ Reply to Thread
Results 1 to 4 of 4

VBA Index/match Error 1004

  1. #1
    Registered User
    Join Date
    08-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA Index/match Error 1004

    I'm trying to do a 2 way match using VBA, the lookup range is dynamic.

    Both lastRow and lookUpvalue are set as double

    Please Login or Register  to view this content.
    Not sure if the ranges are not written correctly. any help is appreciated. Thanks

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,553

    Re: VBA Index/match Error 1004

    Well, this bit's wrong:
    Please Login or Register  to view this content.
    Looks like it needs an "& lastrow" adding.

    Counters relating to rows would normally be Long. So, both lastrow and i should be Long. lookUpvalue would be whatever you expect to get back ... but you might get an error if it's, say, blank. Maybe safer to make it a Variant.

    If either of the Matches fail, you will get an Error, so you would need to use On Error Resume Next to start error trapping and then test whether or not the formula returned an error.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    08-08-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VBA Index/match Error 1004

    Thanks so much!

    I have made the lookUpvalue into a variant, here's the entire code:

    Please Login or Register  to view this content.
    Now im getting a type mismatch error on the first IF statement, comparing a value to the variant. But when I add a msgbox for the lookupvalue, it seems to be returning the correct values going through the loop. Do I have to add something to it to reformat the variant?

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA Index/match Error 1004

    What happens if you change the code to this?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ 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. runtime error 1004 unable to get match property
    By AAvcal71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-16-2014, 03:10 PM
  2. [SOLVED] Match & Index code results in Runtime error 1004
    By DJvdW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2013, 03:52 AM
  3. Replies: 3
    Last Post: 05-02-2013, 01:31 AM
  4. [SOLVED] WorksheetFunction.match run time error '1004' with numbers but not text
    By Hussar13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2013, 05:31 PM
  5. worksheetfunction.match giving run time error '1004'
    By devo2511 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-15-2010, 04:47 PM

Tags for this Thread

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