+ Reply to Thread
Results 1 to 9 of 9

Return one value if data exists, another if data doesn't exist

  1. #1
    Registered User
    Join Date
    07-14-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    43

    Return one value if data exists, another if data doesn't exist

    Hi,
    I'm hoping someone can help.

    I have a spreadsheet "A" with 5-digit numbers in column A and there are over 10K rows.

    Then I have a spreadsheet "B" with 5-digit numbers in column A and there are only 223 rows.

    IF a value in spreadsheet A column A matches spreadsheet B column A, I'd like spreadsheet B column B to log "U". If not, I'd like spreadsheet B column B to log "R." At the end of the day, I'd like all 223 rows in spreadsheet B column B to have either "U" or "R" assigned. Could someone please help?

    Thanks!
    ~S

  2. #2
    Registered User
    Join Date
    01-19-2015
    Location
    Poland
    MS-Off Ver
    2013
    Posts
    59

    Re: Return one value if data exists, another if data doesn't exist

    Hello,

    Please loot at the solution I attached in a file below:

    s1.xlsx

    I used functions: VLOOKUP, IF and ISERROR.

    Regards,
    Alex

  3. #3
    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,461

    Re: Return one value if data exists, another if data doesn't exist

    You can use COUNTIF to check if a number in sheet B exists in sheet A. And then you can use a simple IF function to flag U or R.

    Maybe post a sample workbook ... or are there two workbooks?

    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


  4. #4
    Registered User
    Join Date
    07-14-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Return one value if data exists, another if data doesn't exist

    TMS, thanks so much!

    Here's are the two workbooks - please advise.

    Best,
    ~S
    Attached Files Attached Files

  5. #5
    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,461

    Re: Return one value if data exists, another if data doesn't exist

    Assuming workbook A is open, then, cell B2:
    Formula: copy to clipboard
    Please Login or Register  to view this content.




    Regards, TMS

  6. #6
    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,461

    Re: Return one value if data exists, another if data doesn't exist

    Should note that if workbook A is closed, you'll get #VALUE! errors

  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,461

    Re: Return one value if data exists, another if data doesn't exist

    You can use this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    or this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    with a closed workbook.

    Change the username as required.

    Note that it is MUCH better to have a defined range rather than searching the whole column.


    Regards, TMS

  8. #8
    Registered User
    Join Date
    07-14-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Return one value if data exists, another if data doesn't exist

    Excellent tip, TMS!!!
    Thanks so very much :-)
    ~S

  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,461

    Re: Return one value if data exists, another if data doesn't exist

    You're welcome. 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)

Similar Threads

  1. [SOLVED] Code to paste form data to next available row if cb1 value doesn't exist in column a
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-08-2014, 06:20 PM
  2. [SOLVED] Counting Data Which Doesn't Exist..
    By tommyfernandez in forum Excel General
    Replies: 8
    Last Post: 07-31-2013, 02:28 PM
  3. Lsit From Data Validation References Sheet That Doesn't Exist!
    By clattenburg cake in forum Excel General
    Replies: 2
    Last Post: 07-25-2013, 11:49 AM
  4. Replies: 0
    Last Post: 03-10-2013, 04:19 PM
  5. Cell References data that doesn't exist?
    By hokeyplyr48 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-31-2008, 05:41 PM

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