+ Reply to Thread
Results 1 to 14 of 14

VLOOKUP unwanted date formatting

  1. #1
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    VLOOKUP unwanted date formatting

    Hi guys,

    I've scoured the web but can't find an easy way to get around this, hope you can help.

    I have two columns of data - a code in 012345-1 format and a location in 01-02-03 format. The latter is NOT a date, it just happens to be in the same format.

    I'm using a Vlookup formula to return the location in a new sheet but it keeps switching the first two pairs of numbers around as if it's a date ie 01-02-03 becomes 02-01-03.

    I have tried changing the format of the cells on both sheets to everything in the list including special and custom and I've tried changing the date setting of the sheet to 1904 system - all to no avail. I just can't convince Excel that the location is NOT a date.

    Can anyone help?

  2. #2
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: VLOOKUP unwanted date formatting

    you could try wrap the TEXT function around your vlookup.
    Please Login or Register  to view this content.
    it should return your lookup as a text string in the "00-00-00" format then.
    2+2=5 for extremely large values of 2.

  3. #3
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: VLOOKUP unwanted date formatting

    i think the format in that code may not return what you need if the values have leading zeros
    try replacing the last part with
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VLOOKUP unwanted date formatting

    Thanks Ian

    =TEXT(VLOOKUP(J9,'[other-worksheet.xlsx]Sheet1'!$D$3:$I$1151,1,TRUE),"0##\-00##\-0##\")

    It's returning - #VALUE!

    With FALSE I'm getting #N/A

    Sure this is something really obvious that I'm missing

  5. #5
    Forum Contributor ianh's Avatar
    Join Date
    11-19-2010
    Location
    Newcastle
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: VLOOKUP unwanted date formatting

    could be the extra \ on the end of the format

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: VLOOKUP unwanted date formatting

    Really you need the source data formatted as text rather than a date, then the VLOOKUP wouldn't change it. How is the source data derived?
    Audere est facere

  7. #7
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VLOOKUP unwanted date formatting

    D'oh. Removed it and the error remains

  8. #8
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VLOOKUP unwanted date formatting

    The source cells are formatted as text, it's just that the data is in a date format.

  9. #9
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: VLOOKUP unwanted date formatting

    Quote Originally Posted by vicshippers View Post
    The source cells are formatted as text.....
    Are you sure? If one of the source cells is C2 then what does this formula give you

    =ISNUMBER(C2)

    If the answer is TRUE then the cell is formatted as a date or number. I suspect the answer will be TRUE because VLOOKUP shouldn't change the result if it's text formatted

  10. #10
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VLOOKUP unwanted date formatting

    It's coming up as FALSE.

    I've changed the formatting of every cell on the sheet to TEXT to make doubley sure, but still getting the same.
    Last edited by vicshippers; 12-09-2011 at 07:21 AM. Reason: Additional info added

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: VLOOKUP unwanted date formatting

    Is this the original VLOOKUP you are using?

    =VLOOKUP(J9,'[other-worksheet.xlsx]Sheet1'!$D$3:$I$1151,1,TRUE)

    Note that by using 1 as the "column index" argument you will be returning a value from the lookup range, column D. Is that the intention? TRUE as 4th argument also implies that '[other-worksheet.xlsx]Sheet1'!$D$3:$D$1151 is sorted ascending, is that the case?

  12. #12
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VLOOKUP unwanted date formatting

    I've managed to extrapolate an example, this should clear the fog for you!
    Attached Files Attached Files

  13. #13
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: VLOOKUP unwanted date formatting

    If you are looking up G6 in column D and trying to return the corresponding value from column C then you can't use VLOOKUP usually (VLOOKUP can only be used to retrieve data from columns to the right). For this you need INDEX and MATCH, try this formula

    =INDEX($C$3:$C$1151,MATCH(G6,$D$3:$D$1151,0))&""

  14. #14
    Registered User
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VLOOKUP unwanted date formatting

    You are wonderful. Thank you so much! Never used INDEX/MATCH...always learning!

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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