+ Reply to Thread
Results 1 to 12 of 12

If countif equals then lookup?!?

  1. #1
    Registered User
    Join Date
    01-17-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2016
    Posts
    34

    Question If countif equals then lookup?!?

    Hello everyone,

    First of all, this is the first time I have posted here because it is the first time I have not been able to find the answer else where on the forums. Kudos to everyone who helps out on here. We are the silent majority who thank you.

    What I am trying to do is this;

    If a range of cells contains a specific number then lookup some data. This is the formula that I am using.

    =IF((COUNTIF(G7:G53;1)=1);LOOKUP(1;G7:G53;D7:D53);"")

    So if the number one is contained just once anywhere from G7 to G53 then it will look up the corresponding data from D7 to D53. I have this set up four times so that the corresponding data in column D is supplied when the number one appears once, number two appears once; number three appears once or the number four appears once. If the numbers that are entered into column G are in the order 1234 then it works fine. If the numbers are entered in a different order, (4321 for example) it doesn't.

    Can anyone explain where I am going wrong?

    Thanks

    L

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: If countif equals then lookup?!?

    Where does the formula appear four times, adjusted by the number?

    Suggest you post a sample workbook.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    01-17-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: If countif equals then lookup?!?

    Albert 4
    Bobby 2
    Charles 3
    David
    Eddie
    Frank 1
    Gordon

    What I would like is that in a separate part of the same table, the data, is returned:

    Frank
    Bobby
    Charles
    Albert

    When the numbers are in order, it works. When they aren't, it doesn't

    L

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: If countif equals then lookup?!?

    That's not a workbook, that's a list. I need to see where the data is and where your formulae are.

    Regards, TMS

  5. #5
    Registered User
    Join Date
    01-17-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: If countif equals then lookup?!?

    Book1.xls

    Here's a sample

    If you swap the numbers for 1234, it works.

    I don't get it...

  6. #6
    Registered User
    Join Date
    01-17-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: If countif equals then lookup?!?

    Quote Originally Posted by TMShucks View Post
    That's not a workbook, that's a list. I need to see where the data is and where your formulae are.

    Regards, TMS
    I have now done so. I couldn't work out how to do it at first.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: If countif equals then lookup?!?

    =IF(COUNTIF($C$2:$C$8,ROW(A1))=1,INDEX($B$2:$B$8,MATCH(ROW(A1),$C$2:$C$8,0)),"")


    I think your LOOKUP data would need to be in ascending order. Hence, 1234 works, 4321 doesn't.


    Regards, TMS

  8. #8
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: If countif equals then lookup?!?

    Using the help in excel:
    http://support.microsoft.com/kb/324986


    Important The values in lookup_vector must be placed in ascending order. For example, -2, -1, 0, 1, 2 or A-Z or FALSE, TRUE. If you do not do so, LOOKUP may not give the correct value. Uppercase and lowercase text are equivalent.
    I suggest this instead:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    change the RED values for each condition

    Hope this helps
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: If countif equals then lookup?!?

    change the RED values for each condition

    Or use my formula and just drag down.


    Regards, TMS

  10. #10
    Registered User
    Join Date
    01-17-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: If countif equals then lookup?!?

    It works, it works!!!!

    Thank-you very much. Have a biscuit.

    L

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: If countif equals then lookup?!?

    You're welcome. I'll hold the biscuits, still working through the Christmas chocolates.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: If countif equals then lookup?!?

    Thanks for the rep.

+ 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