+ Reply to Thread
Results 1 to 6 of 6

Multiple criteria options in a formula

  1. #1
    Forum Contributor
    Join Date
    08-22-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2003
    Posts
    129

    Multiple criteria options in a formula

    Currently using ({5,"*5*"}) to search for numbers and text that contain 5.

    Curious how I can make it look for 5 or 6. So if any of the cells in the range contain either 5 or 6, it will work.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: Multiple criteria options in a formula

    Try this:

    {5,"*5*",6,"*6*"}

    although it does depend on the functions you are using for the search (I imagine this is still the COUNTIF problem from earlier).

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    08-22-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2003
    Posts
    129

    Re: Multiple criteria options in a formula

    This was for a SUMIF problem actually, but I had no idea it differed depending on the function.

    Interestingly, this sums the 1's as expected but doesn't seem to sum the 7's but also does not bring up an error.

    Full code:
    Please Login or Register  to view this content.
    Edit: I am currently using the temporary solution of using 2 seperate cells to count 1's and 7's and then just adding the results of these 2 cells together. This works, but it's obviously not ideal.
    Last edited by ThomasCarter; 09-14-2012 at 11:22 AM.

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Multiple criteria options in a formula

    I don't think you can use an array of values like that in SUMIF.

    You could try this array formula.

    {=SUM(IF(ISNUMBER(SEARCH({1,7},A4:A999)),B4:B999))}

    Array formulas are entered using the key combination of Ctrl+Shift+Enter.
    Excel automatically adds the curly brackets.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  5. #5
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Multiple criteria options in a formula

    I don't think you can use an array of values like that in SUMIF.
    You probably can. Just enclose the SUMIF in a SUM function. Hence,

    =SUM(SUMIF(A4:A999,({1,"*1*",7,"*7*"}),B4:B999))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  6. #6
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Multiple criteria options in a formula

    My comment was related strictly to using such an array within SUMIF - not a nested formula as you show.
    That array will not work in SUMIF.

    Good job on the formula. I did not think of nesting SUM approach.

+ 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