+ Reply to Thread
Results 1 to 9 of 9

Vlookup that returns look up if a cell on the same row has a specific value

Hybrid View

  1. #1
    Registered User
    Join Date
    03-29-2013
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    22

    Vlookup that returns look up if a cell on the same row has a specific value

    Table 9

    A B C
    1 john 1/1/12 P
    2 Steve 12/1/12 A
    3 Khan 1/4/13 A


    with the above mock table I'm looking for a vlookup formula or vba that comprises a lookup value that matches the name and looks up the date only if the value in column C is 'P'.



    Vlookup example.xlsx

    Ive attached a sheet for your viewing.

    Many thanks
    Last edited by hb316; 08-15-2013 at 06:52 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    Hi
    Try this formula in B11 of your sample:

    =IF(VLOOKUP([@Name],Table2[#All],3,FALSE)="P",(VLOOKUP([@Name],Table2[#All],2,FALSE)),"")

    Tony

  3. #3
    Registered User
    Join Date
    07-08-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    Hi hb316,
    I am new to this but try the example I have attached. Prob is I moved the 3rd column to be the 1st due to the VLOOKUP syntax. Also cells in the answer need to be formatted to date.

    Please read down further for corrections noted by other users.
    Attached Files Attached Files
    Last edited by Dexamphetamine; 08-15-2013 at 08:08 AM. Reason: Updated information for post

  4. #4
    Forum Contributor
    Join Date
    08-14-2013
    Location
    Here and there
    MS-Off Ver
    Excel 2010
    Posts
    376

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    Dexamphetamine your effort was commendable but you posted a simple VLOOKUP formula without any 'Absolute' references hence when you dragged the formula down the cell references are incorrect - see your cells C11, C12 & C13. Your formula looks like this =VLOOKUP(A6,A1:C3,3,0), whereas with a formula you want to drag that has references to fixed cells it should have looked like this: =VLOOKUP($A$6,$A$1:$C$3,3,0)

    What you needed to do was make the references in the formula Absolute by selecting the F4 key when you inserted the cell reference in the formula. The $ sign makes a column or row 'Absolute' e.g. $A6 means the column is Absolute and the row in 'Relative', conversely A$6 means the row is Absolute so then $A$6 means both the column AND the row are Absolute so then $A$6 is an 'Absolute cell reference, and in your formula $A$1:$C$3 means the range is also Absolute and will not change when dragged down or across and this is important. An 'Absolute' cell reference will never change.

    Cheers
    Last edited by Ursul; 08-15-2013 at 07:33 AM. Reason: I found an important mistake in my post

  5. #5
    Registered User
    Join Date
    07-08-2013
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    Thanks Ursul,
    You are absolutely correct. I forgot about the F4 key (I usually just type it directly into the formula at the time) and as such was only useful for the one cell, with all copied cells being incorrect. Hope hb316 sees your correction before finishing his/her project!

    Regards,
    Finchy/Dexamphet!
    Last edited by Dexamphetamine; 08-15-2013 at 07:59 AM. Reason: spelling

  6. #6
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    Hi
    VLOOKUP only works left to right so the way around this is to add a new column D and link it to Column A. Column D can then be hidden from view so as not to confuse anyone.
    See sample attached.
    Tony
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    03-29-2013
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    sorry I was meant to include 'looks up the MOST RECENT date', the dates should only be the dates where the row cell in column C is 'P'.

    The formula I have for that is a straight forward vlookup with MAX function to bring up the most recent date...
    MAX(VLOOKUP(Table3[[#This Row],[Name]],Table2,2,FALSE))
    however this doesnt skip the 'A' (Absent) dates

    updated sheet
    Vlookup example.xlsx

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    =MAX(INDEX(INDEX($A$2:$A$7=A11,0)*INDEX($C$2:$C$7="p",0)*$B$2:$B$7,0)) should do it
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  9. #9
    Registered User
    Join Date
    03-29-2013
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Vlookup that returns look up if a cell on the same row has a specific value

    martindwilson that seems to have done the job!! Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] get cell value if vlookup returns a specific data
    By amar05 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-11-2013, 10:57 AM
  2. choose one specific return from multiple returns of Vlookup
    By loaiky in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-28-2013, 12:06 PM
  3. Replies: 3
    Last Post: 12-21-2012, 05:33 AM
  4. Replies: 6
    Last Post: 08-16-2011, 07:45 PM
  5. Vlookup-Blank cell returns Zero
    By Justinmih in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2008, 02:35 PM

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