+ Reply to Thread
Results 1 to 8 of 8

Return a value if criteria contained in cell

  1. #1
    jhicsupt
    Guest

    Return a value if criteria contained in cell

    I would like to return a value if criteria is met.

    If A2 contains the word "apples", then in cell B2, write "apples".
    If A2 contains the word "oranges, then in cell B2, write "oranges".
    If A2 does not contain the words "apples" or "oranges", leave the cell blank.

    Can you help me with a formula for this?

    Thanks in advance.

  2. #2
    JMB
    Guest

    RE: Return a value if criteria contained in cell

    IF(OR(A2="apples",A2="oranges"),A2,"")

    "jhicsupt" wrote:

    > I would like to return a value if criteria is met.
    >
    > If A2 contains the word "apples", then in cell B2, write "apples".
    > If A2 contains the word "oranges, then in cell B2, write "oranges".
    > If A2 does not contain the words "apples" or "oranges", leave the cell blank.
    >
    > Can you help me with a formula for this?
    >
    > Thanks in advance.


  3. #3
    Biff
    Guest

    Re: Return a value if criteria contained in cell

    Hi!

    Try one of these:

    =IF(OR(A2={"apples","oranges"}),A2,"")

    Biff

    "jhicsupt" <[email protected]> wrote in message
    news:[email protected]...
    >I would like to return a value if criteria is met.
    >
    > If A2 contains the word "apples", then in cell B2, write "apples".
    > If A2 contains the word "oranges, then in cell B2, write "oranges".
    > If A2 does not contain the words "apples" or "oranges", leave the cell
    > blank.
    >
    > Can you help me with a formula for this?
    >
    > Thanks in advance.




  4. #4
    jhicsupt
    Guest

    Re: Return a value if criteria contained in cell

    In cell A2, it could be "apples and pears" or it could be "oranges and
    pears". What I want to do is in cell B2, just return either "apples" or
    "oranges", disregarding the "and pears".

    How would I do that?

    Thanks for the quick response.

    "Biff" wrote:

    > Hi!
    >
    > Try one of these:
    >
    > =IF(OR(A2={"apples","oranges"}),A2,"")
    >
    > Biff
    >
    > "jhicsupt" <[email protected]> wrote in message
    > news:[email protected]...
    > >I would like to return a value if criteria is met.
    > >
    > > If A2 contains the word "apples", then in cell B2, write "apples".
    > > If A2 contains the word "oranges, then in cell B2, write "oranges".
    > > If A2 does not contain the words "apples" or "oranges", leave the cell
    > > blank.
    > >
    > > Can you help me with a formula for this?
    > >
    > > Thanks in advance.

    >
    >
    >


  5. #5
    Biff
    Guest

    Re: Return a value if criteria contained in cell

    Well, that's a whole different animal!

    Try this:

    =IF(ISNUMBER(SEARCH("apples",A2)),"apples",IF(ISNUMBER(SEARCH("oranges",A2)),"oranges",""))

    What if it's "apples or oranges" or "oranges or apples" ?

    You'd be better off using a cell to hold the criteria:

    A1 = apples
    B1 = oranges

    =IF(ISNUMBER(SEARCH(A1,A2)),A1,IF(ISNUMBER(SEARCH(B1,A2)),B1,""))

    Biff

    "jhicsupt" <[email protected]> wrote in message
    news:[email protected]...
    > In cell A2, it could be "apples and pears" or it could be "oranges and
    > pears". What I want to do is in cell B2, just return either "apples" or
    > "oranges", disregarding the "and pears".
    >
    > How would I do that?
    >
    > Thanks for the quick response.
    >
    > "Biff" wrote:
    >
    >> Hi!
    >>
    >> Try one of these:
    >>
    >> =IF(OR(A2={"apples","oranges"}),A2,"")
    >>
    >> Biff
    >>
    >> "jhicsupt" <[email protected]> wrote in message
    >> news:[email protected]...
    >> >I would like to return a value if criteria is met.
    >> >
    >> > If A2 contains the word "apples", then in cell B2, write "apples".
    >> > If A2 contains the word "oranges, then in cell B2, write "oranges".
    >> > If A2 does not contain the words "apples" or "oranges", leave the cell
    >> > blank.
    >> >
    >> > Can you help me with a formula for this?
    >> >
    >> > Thanks in advance.

    >>
    >>
    >>




  6. #6
    jhicsupt
    Guest

    Re: Return a value if criteria contained in cell

    This worked perfectly. Now another question -- do you know how I would put
    this in an Access query?

    I am using Excel to run the query, but after thinking, would rather do it
    right in Access and let it come over from the query. Or should I post this
    question on the Access group?

    "Biff" wrote:

    > Well, that's a whole different animal!
    >
    > Try this:
    >
    > =IF(ISNUMBER(SEARCH("apples",A2)),"apples",IF(ISNUMBER(SEARCH("oranges",A2)),"oranges",""))
    >
    > What if it's "apples or oranges" or "oranges or apples" ?
    >
    > You'd be better off using a cell to hold the criteria:
    >
    > A1 = apples
    > B1 = oranges
    >
    > =IF(ISNUMBER(SEARCH(A1,A2)),A1,IF(ISNUMBER(SEARCH(B1,A2)),B1,""))
    >
    > Biff
    >
    > "jhicsupt" <[email protected]> wrote in message
    > news:[email protected]...
    > > In cell A2, it could be "apples and pears" or it could be "oranges and
    > > pears". What I want to do is in cell B2, just return either "apples" or
    > > "oranges", disregarding the "and pears".
    > >
    > > How would I do that?
    > >
    > > Thanks for the quick response.
    > >
    > > "Biff" wrote:
    > >
    > >> Hi!
    > >>
    > >> Try one of these:
    > >>
    > >> =IF(OR(A2={"apples","oranges"}),A2,"")
    > >>
    > >> Biff
    > >>
    > >> "jhicsupt" <[email protected]> wrote in message
    > >> news:[email protected]...
    > >> >I would like to return a value if criteria is met.
    > >> >
    > >> > If A2 contains the word "apples", then in cell B2, write "apples".
    > >> > If A2 contains the word "oranges, then in cell B2, write "oranges".
    > >> > If A2 does not contain the words "apples" or "oranges", leave the cell
    > >> > blank.
    > >> >
    > >> > Can you help me with a formula for this?
    > >> >
    > >> > Thanks in advance.
    > >>
    > >>
    > >>

    >
    >
    >


  7. #7
    Biff
    Guest

    Re: Return a value if criteria contained in cell

    I know nothing about Access. You should post that question in an Access
    forum but you could also keep an eye on this thread in case someone chimes
    in with a solution.

    Biff

    "jhicsupt" <[email protected]> wrote in message
    news:[email protected]...
    > This worked perfectly. Now another question -- do you know how I would
    > put
    > this in an Access query?
    >
    > I am using Excel to run the query, but after thinking, would rather do it
    > right in Access and let it come over from the query. Or should I post
    > this
    > question on the Access group?
    >
    > "Biff" wrote:
    >
    >> Well, that's a whole different animal!
    >>
    >> Try this:
    >>
    >> =IF(ISNUMBER(SEARCH("apples",A2)),"apples",IF(ISNUMBER(SEARCH("oranges",A2)),"oranges",""))
    >>
    >> What if it's "apples or oranges" or "oranges or apples" ?
    >>
    >> You'd be better off using a cell to hold the criteria:
    >>
    >> A1 = apples
    >> B1 = oranges
    >>
    >> =IF(ISNUMBER(SEARCH(A1,A2)),A1,IF(ISNUMBER(SEARCH(B1,A2)),B1,""))
    >>
    >> Biff
    >>
    >> "jhicsupt" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > In cell A2, it could be "apples and pears" or it could be "oranges and
    >> > pears". What I want to do is in cell B2, just return either "apples"
    >> > or
    >> > "oranges", disregarding the "and pears".
    >> >
    >> > How would I do that?
    >> >
    >> > Thanks for the quick response.
    >> >
    >> > "Biff" wrote:
    >> >
    >> >> Hi!
    >> >>
    >> >> Try one of these:
    >> >>
    >> >> =IF(OR(A2={"apples","oranges"}),A2,"")
    >> >>
    >> >> Biff
    >> >>
    >> >> "jhicsupt" <[email protected]> wrote in message
    >> >> news:[email protected]...
    >> >> >I would like to return a value if criteria is met.
    >> >> >
    >> >> > If A2 contains the word "apples", then in cell B2, write "apples".
    >> >> > If A2 contains the word "oranges, then in cell B2, write "oranges".
    >> >> > If A2 does not contain the words "apples" or "oranges", leave the
    >> >> > cell
    >> >> > blank.
    >> >> >
    >> >> > Can you help me with a formula for this?
    >> >> >
    >> >> > Thanks in advance.
    >> >>
    >> >>
    >> >>

    >>
    >>
    >>




  8. #8
    Dan
    Guest

    Re: Return a value if criteria contained in cell

    If you are using Access, I would assume you are more using a table.

    Follow SQL could do.
    SELECT
    CASE
    WHEN x like '%apples%" THEN "apples"
    WHEN x like '%oranges%" THEN "orange"
    ELSE
    ""
    FROM
    table list


    "jhicsupt" wrote:

    > This worked perfectly. Now another question -- do you know how I would put
    > this in an Access query?
    >
    > I am using Excel to run the query, but after thinking, would rather do it
    > right in Access and let it come over from the query. Or should I post this
    > question on the Access group?
    >
    > "Biff" wrote:
    >
    > > Well, that's a whole different animal!
    > >
    > > Try this:
    > >
    > > =IF(ISNUMBER(SEARCH("apples",A2)),"apples",IF(ISNUMBER(SEARCH("oranges",A2)),"oranges",""))
    > >
    > > What if it's "apples or oranges" or "oranges or apples" ?
    > >
    > > You'd be better off using a cell to hold the criteria:
    > >
    > > A1 = apples
    > > B1 = oranges
    > >
    > > =IF(ISNUMBER(SEARCH(A1,A2)),A1,IF(ISNUMBER(SEARCH(B1,A2)),B1,""))
    > >
    > > Biff
    > >
    > > "jhicsupt" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > In cell A2, it could be "apples and pears" or it could be "oranges and
    > > > pears". What I want to do is in cell B2, just return either "apples" or
    > > > "oranges", disregarding the "and pears".
    > > >
    > > > How would I do that?
    > > >
    > > > Thanks for the quick response.
    > > >
    > > > "Biff" wrote:
    > > >
    > > >> Hi!
    > > >>
    > > >> Try one of these:
    > > >>
    > > >> =IF(OR(A2={"apples","oranges"}),A2,"")
    > > >>
    > > >> Biff
    > > >>
    > > >> "jhicsupt" <[email protected]> wrote in message
    > > >> news:[email protected]...
    > > >> >I would like to return a value if criteria is met.
    > > >> >
    > > >> > If A2 contains the word "apples", then in cell B2, write "apples".
    > > >> > If A2 contains the word "oranges, then in cell B2, write "oranges".
    > > >> > If A2 does not contain the words "apples" or "oranges", leave the cell
    > > >> > blank.
    > > >> >
    > > >> > Can you help me with a formula for this?
    > > >> >
    > > >> > Thanks in advance.
    > > >>
    > > >>
    > > >>

    > >
    > >
    > >


+ 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