+ Reply to Thread
Results 1 to 3 of 3

Returning the wrong values...but not in the Immediate window?

  1. #1

    Returning the wrong values...but not in the Immediate window?

    I am trying to use the following code to capture a couple of dates from
    cells.

    dStart = Application.WorksheetFunction.VLookup(c.Offset(0,
    -COff).Value, _
    Sheets("Update").Range(Cells(11, 2), Cells(LastActivity,
    18)), 2, False)
    dEnd = Application.WorksheetFunction.VLookup(c.Offset(0,
    -COff).Value, _
    Sheets("Update").Range(Cells(11, 2), Cells(LastActivity,
    18)), 3, False)

    Both dStart and dEnd are dimensioned as Dates and the cells to which
    they reference contain dates. The references work fine. In fact, from
    the Immediates Window:

    ?Application.WorksheetFunction.VLookup(c.Offset(0,
    -COff).Value, _
    Sheets("Update").Range(Cells(11, 2),
    Cells(LastActivity, 18)), 3, False)
    38825
    ?Application.WorksheetFunction.VLookup(c.Offset(0,
    -COff).Value, _
    Sheets("Update").Range(Cells(11, 2),
    Cells(LastActivity, 18)), 2, False)
    38813

    The problem is that the values assigned to dStart and dEnd are
    0....that is, #12:00:00 AM#. I've tried dimensioning them as integers
    (which should have produced an overflow error) and variants. The
    assigned values are always 0. So I don't think it is a data type
    mismatch.

    The dates I am trying to retrieve are calculated via formulas. But it
    seems to me that is not an issue since I get the dateserial in the
    immediates window. It may also be important to note that the sheet
    from which the dates are being read is protected. The cells for dStart
    are unlocked and dEnd cells are locked. I think I can rule out a
    protection issue, since I get 0 for both.

    I've hurt my little brain on this one. ANY help is greatly
    appreciated.

    Thanks,
    John


  2. #2
    WhytheQ
    Guest

    Re: Returning the wrong values...but not in the Immediate window?

    should the bit of code:
    Sheets("Update").Range(Cells(11, 2), Cells(LastActivity,18))

    read more like:
    Sheets("Update").Range(Sheets("Update").Cells(11, 2),
    Sheets("Update").Cells(LastActivity,18))


    ?
    J


  3. #3

    Re: Returning the wrong values...but not in the Immediate window?

    Sheets("Update").Range(Cells(11, 2), Cells(LastActivity,18)) defines
    the table array needed for the vlookup function.

    I'm looking for {c.Offset(0,-COff).Value}, which is a text string, in
    the first column of {Sheets("Update").Range(Cells(11, 2),
    Cells(LastActivity,18))} and returning the date contained in the 2nd
    (for dStart and 3rd for dEnd) column of that table array.

    Thanks,
    John


+ 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