+ Reply to Thread
Results 1 to 3 of 3

Error 2042 with application.vlookup for date

Hybrid View

maacmaac Error 2042 with... 04-20-2013, 10:51 PM
TMS Re: Error 2042 with... 04-21-2013, 03:44 AM
jindon Re: Error 2042 with... 04-21-2013, 03:57 AM
  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Error 2042 with application.vlookup for date

    I'm trying to lookup up a value in a table. The lookup range is A:E. Column A is a date; Column E is a number. I am not sure why the statement is not returning a value. Column A is formatted as a date. I have the variable myDateEnd declared as a date. When I step through the code I can see a value for myDateEnd and the same value is in the lookup table. I can't figure out why IdxValueEnd is not returning a value (I tried to declare as Long and as Variant but neither method helps). Thanks in advance for any comments.
        IdxValueEnd = Application.VLookup(myDateEnd, wkbData.Worksheets(1).Range("A:E"), 5, True)

  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
    48,515

    Re: Error 2042 with application.vlookup for date

    I would suggest that you post a sample workbook with some typical data that exhibits the problem.

    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
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Error 2042 with application.vlookup for date

    Perhaps
    IdxValueEnd = Application.VLookup(fix(cdbl(myDateEnd)), wkbData.Worksheets(1).Range("A:E"), 5, True)

+ 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