+ Reply to Thread
Results 1 to 2 of 2

Vlookup does not find closest match (dates)

Hybrid View

Stefan.hagnesten Vlookup does not find closest... 08-03-2009, 10:37 AM
DonkeyOte Re: Vlookup does not find... 08-03-2009, 10:38 AM
  1. #1
    Registered User
    Join Date
    07-01-2009
    Location
    Sweden
    MS-Off Ver
    Excel 2007
    Posts
    3

    Vlookup does not find closest match (dates)

    Hi,

    I have a very confusing problem, my vlookup function in vba does not find the closest date in a sorted data set containing dates. It does so when i apply it to a cell using the exact same data range, the exact same date and the exact same data. my code is simply:

    rngname = activeworkbook.sheets(shtnbr).cells(5,19) ' Data name
    tempname = range(rngname).worksheet.name
    r = ActiveWorkbook.Worksheets(tempname).Range(rngName)
    msgbox Application.VLookup(ActiveWorkbook.Sheets(shtNbr).Cells(19, 4).Value, r, 1)

    where the cell value in cell(19,4) is the date and rngname is the range to search.

    What could possibly be wrong in my code? I find it very weird that it does work when i apply it to a cell but not in my code...

    Thanks!

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Vlookup does not find closest match (dates)

    First, please note below:

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

+ 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