+ Reply to Thread
Results 1 to 6 of 6

Using IF to return 1 or 0 for a range of cells

  1. #1
    Registered User
    Join Date
    04-23-2020
    Location
    Surrey, England
    MS-Off Ver
    MS Office 365
    Posts
    4

    Using IF to return 1 or 0 for a range of cells

    I'm a novice and using =IF(A2="a",1,0) in order to return '1' if 'a' is found in cell A2 or '0' if 'a' is not found in A2. How can I get it to return '1' or '0' if 'a' is found in either of the cells A2 to C2? I wrongly thought =IF(A2:C2="a",1,0) would do the trick but seems I'm wrong, thanks

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,908

    Re: Using IF to return 1 or 0 for a range of cells

    Welcome to the forum.

    Try this:

    =VALUE(COUNTIF(A1:C1,"a")>0)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-23-2020
    Location
    Surrey, England
    MS-Off Ver
    MS Office 365
    Posts
    4

    Re: Using IF to return 1 or 0 for a range of cells

    Excellent Ali, thanks - you set me on the right path. It returned an error so I had to tweak slightly to this: =VALUE(COUNTIF(A2:C2,"a"))

    Appreciated!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,908

    Re: Using IF to return 1 or 0 for a range of cells

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  5. #5
    Registered User
    Join Date
    04-23-2020
    Location
    Surrey, England
    MS-Off Ver
    MS Office 365
    Posts
    4

    Re: Using IF to return 1 or 0 for a range of cells

    Well I thought that worked until I came across this situation for which it didn't work:

    The formula doesn't work if the respondent has answered the same way to 2 or 3 parts of a question. I only need it to return '1' for each part instead of summing the responses.
    Difficult to explain so I've attached a section of the sheet. The responses are coded 'a' to 'f' (strongly agree to Don't know) and there are 3 parts to the question
    so some respondents will have responded e.g. strongly agree to 2 parts of the question so the formula is going to return 2.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-23-2020
    Location
    Surrey, England
    MS-Off Ver
    MS Office 365
    Posts
    4

    Re: Using IF to return 1 or 0 for a range of cells

    No problem, I think I've sorted my problem with a simple IF formula
    Thanks again

+ 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. Return multiple cells if one cell is equal to other cells in a range
    By saintvinni in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-07-2020, 07:22 PM
  2. [SOLVED] Search range of cells, return cell locations of all cells of particular colour
    By AJB611 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-03-2017, 11:50 AM
  3. [SOLVED] Return a value for finding range of cells in another range of cells
    By kuzner in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-16-2016, 07:04 PM
  4. [SOLVED] Return non-blank cells from range AND ignore cells with only formula w/o results
    By grafitti in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-06-2014, 08:15 AM
  5. Replies: 1
    Last Post: 09-04-2013, 07:23 AM
  6. Replies: 2
    Last Post: 11-12-2012, 06:26 AM
  7. Replies: 5
    Last Post: 08-29-2012, 03:53 AM

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