+ Reply to Thread
Results 1 to 7 of 7

conditional vlookup

  1. #1
    Registered User
    Join Date
    04-03-2005
    Posts
    58

    conditional vlookup

    I am looking to have a conditional look up. Sample file is attached here.

    I have three sheets in the file. Sheet 1 is where i want to capture last purchase date of an item code, which will be taken from sheet 2008 first, if not available for that item, then it will go to sheet 2007. If it is not available in both of the sheets, then I want the cell to be displayed with "-" & not "#N/A".
    In the last column I want to calculate the number of days from last purchase date to 31-12-08.

    thanks in advance
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    04-16-2009
    Location
    Stellenbosch, South Africa
    MS-Off Ver
    Excel 2003; Excel 2007; Excel 2010; Excel 2013
    Posts
    136

    Re: conditional vlookup

    In Sheet1 cell E5 and copied down to end of range:

    =MAX(IF('2008'!$A$2:$A$100=$A5,'2008'!$C$2:$C$100),IF('2007'!$A$2:$A$100=$A5,'2007'!$C$2:$C$100))

    This is an array formula and should be committed with CONTROL+SHIFT+ENTER and not just ENTER. Format the cells as d-mm-yyyy;;-

    In F5 and copied to end of range:

    =F2-E5

    Format this cell as general or as a number, not a date.
    Regards

    Jon (Excel 2003, 2007, 2010, 2013)

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,053

    Re: conditional vlookup

    Try this in E5 and extend down...

    =IF(ISNA(VLOOKUP(A5;'2008'!$A$2:$D$2;3;FALSE));IF(ISNA(VLOOKUP(A5;'2007'!$A$2:$D$2;3;FALSE));"-";VLOOKUP(A5;'2007'!$A$2:$D$2;3;FALSE));VLOOKUP(A5;'2008'!$A$2:$D$2;3;FALSE))

    In F5:

    =IF(E5="-";"-";E5-$F$2)
    Last edited by zbor; 05-18-2009 at 01:47 AM.
    Never use Merged Cells in Excel

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

    Re: conditional vlookup

    Another alternative approach:

    E5: =LOOKUP(10^10,CHOOSE({1,2,3},0,VLOOKUP(A5,'2007'!$A:$C,3,0),VLOOKUP(A5,'2008'!$A:$C,3,0)))
    copy down as required

    Apply Custom Format to E5:Ex of: [=0]"-";dd-mmm-yy

    F5: =IF($E5,$F$2-$E5,"n/a")
    copy down as required

  5. #5
    Registered User
    Join Date
    04-03-2005
    Posts
    58

    Re: conditional vlookup

    Something not working there. i tried those formulas. am attaching the file again with more example & indicating the desired results. the last date of purchase should pop-up between the choice of purchase data for 2 years which is split in 2 different sheets.
    Attached Files Attached Files

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

    Re: conditional vlookup

    Jon's formula (post#2) will return the expected results, note though it is an Array and must be entered with CTRL + SHIFT + ENTER (not just enter)

  7. #7
    Registered User
    Join Date
    04-03-2005
    Posts
    58

    Re: conditional vlookup

    thanks a ton ! it worked..

+ 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