+ Reply to Thread
Results 1 to 8 of 8

If column X is YES and column Y has value return 1

  1. #1
    Registered User
    Join Date
    09-27-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    If column X is YES and column Y has value return 1

    Hi everyone,

    I would like some help on an issue I've got with my spreadsheet in Excel.

    If cell B5 in worksheet X has value YES it should check if I5 has value A, B or C and then return 1. Then check the next row down to B100 -> I100 (it can be a static value since it won't ever be over 100 rows).
    It should then sum up all the 1s and return that number to another worksheet.

    Is this possible to do with a formula or would I have to go with VB?


    Thanks in advance!

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: If column X is YES and column Y has value return 1

    So you're looking to do the whole thing in one formula?

    How about:

    =SUMPRODUCT(--(B5:B100="YES"),--(ISNUMBER(FIND(I5:I100,"ABC"))))

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

    Re: If column X is YES and column Y has value return 1

    could you put that in a workbook and attach it here it's not clear what you are asking
    "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

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

    Re: If column X is YES and column Y has value return 1

    One way:

    =IF(AND(B5="yes",OR(I5="a",I5="b",I5="c")),1,"")

    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


  5. #5
    Registered User
    Join Date
    09-27-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: If column X is YES and column Y has value return 1

    Quote Originally Posted by martindwilson View Post
    could you put that in a workbook and attach it here it's not clear what you are asking
    Sure mate! Look attachment.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: If column X is YES and column Y has value return 1

    OK, on you summary sheet take the spaces out of the sheet names in column A (i.e. change "Sheet 1" to "Sheet1") and then try this formula in column C:

    =SUMPRODUCT(--(INDIRECT("'" & A4 & "'!B5:b100")="YES"),--(ISNUMBER(FIND("~" & INDIRECT("'" & A4 & "'!i5:i100") & "~","~A~B~C~"))))

  7. #7
    Registered User
    Join Date
    09-27-2011
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: If column X is YES and column Y has value return 1

    Quote Originally Posted by Andrew-R View Post
    OK, on you summary sheet take the spaces out of the sheet names in column A (i.e. change "Sheet 1" to "Sheet1") and then try this formula in column C:

    =SUMPRODUCT(--(INDIRECT("'" & A4 & "'!B5:b100")="YES"),--(ISNUMBER(FIND("~" & INDIRECT("'" & A4 & "'!i5:i100") & "~","~A~B~C~"))))
    I really can't get this to work. The "," between INDIRECT and ISNUMBER isn't likeable by Excel and gives me error.
    Just to make all clear from my example file above: the cell C4 in Summary should present the result of Sheet1, which is 3 and the cell C5 in Summary should present the result of Sheet2, which is one.

  8. #8
    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,440

    Re: If column X is YES and column Y has value return 1

    Could be your regional settings. Try changing it to a semi-colon (

+ 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