+ Reply to Thread
Results 1 to 7 of 7

Formula help

Hybrid View

  1. #1
    Daniel Bonallack
    Guest

    Formula help

    I have a text value in cells A1:D1. Let's say that the values read across
    the row:
    A1 = "Duck", B1 = "Duck", C1 = "Cat", D1 = "Duck"

    I want a formula in cell E1 that will return "No" in this case, meaning that
    the items are not all same.

    The bit that makes it too hard for me is that there may be blanks, and the
    blanks should not be counted. So:
    A1 = "Duck", B1 = "", C1 = "Duck", D1="Duck" should be a "Yes" in column E.

    Thanks very much for any help.
    Daniel




  2. #2
    Ron Coderre
    Guest

    RE: Formula help

    Try a variation of this:
    E1: =SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10,A1:A10&""))
    That formula counts the number of non-blank, unique items.

    Does that help?

    ***********
    Regards,
    Ron


    "Daniel Bonallack" wrote:

    > I have a text value in cells A1:D1. Let's say that the values read across
    > the row:
    > A1 = "Duck", B1 = "Duck", C1 = "Cat", D1 = "Duck"
    >
    > I want a formula in cell E1 that will return "No" in this case, meaning that
    > the items are not all same.
    >
    > The bit that makes it too hard for me is that there may be blanks, and the
    > blanks should not be counted. So:
    > A1 = "Duck", B1 = "", C1 = "Duck", D1="Duck" should be a "Yes" in column E.
    >
    > Thanks very much for any help.
    > Daniel
    >
    >
    >


  3. #3
    Daniel Bonallack
    Guest

    RE: Formula help

    Hi Ron

    Thanks for offering a solution, but I'm not sure how to apply it. Maybe my
    example wasn't clear, but I wasn't sure why you have A1:A10 - I'm trying to
    test across the row A1:D1, then copy that formula down to 12,000 rows.

    Hope that clarifies.
    Daniel


    "Ron Coderre" wrote:

    > Try a variation of this:
    > E1: =SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10,A1:A10&""))
    > That formula counts the number of non-blank, unique items.
    >
    > Does that help?
    >
    > ***********
    > Regards,
    > Ron
    >
    >
    > "Daniel Bonallack" wrote:
    >
    > > I have a text value in cells A1:D1. Let's say that the values read across
    > > the row:
    > > A1 = "Duck", B1 = "Duck", C1 = "Cat", D1 = "Duck"
    > >
    > > I want a formula in cell E1 that will return "No" in this case, meaning that
    > > the items are not all same.
    > >
    > > The bit that makes it too hard for me is that there may be blanks, and the
    > > blanks should not be counted. So:
    > > A1 = "Duck", B1 = "", C1 = "Duck", D1="Duck" should be a "Yes" in column E.
    > >
    > > Thanks very much for any help.
    > > Daniel
    > >
    > >
    > >


  4. #4
    Ron Coderre
    Guest

    RE: Formula help

    Um...OK..You want this:
    E1: =SUMPRODUCT((A1:D1<>"")/COUNTIF(A1:D1,A1:D1&""))


    Does that help?

    ***********
    Regards,
    Ron


    "Daniel Bonallack" wrote:

    > Hi Ron
    >
    > Thanks for offering a solution, but I'm not sure how to apply it. Maybe my
    > example wasn't clear, but I wasn't sure why you have A1:A10 - I'm trying to
    > test across the row A1:D1, then copy that formula down to 12,000 rows.
    >
    > Hope that clarifies.
    > Daniel
    >
    >
    > "Ron Coderre" wrote:
    >
    > > Try a variation of this:
    > > E1: =SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10,A1:A10&""))
    > > That formula counts the number of non-blank, unique items.
    > >
    > > Does that help?
    > >
    > > ***********
    > > Regards,
    > > Ron
    > >
    > >
    > > "Daniel Bonallack" wrote:
    > >
    > > > I have a text value in cells A1:D1. Let's say that the values read across
    > > > the row:
    > > > A1 = "Duck", B1 = "Duck", C1 = "Cat", D1 = "Duck"
    > > >
    > > > I want a formula in cell E1 that will return "No" in this case, meaning that
    > > > the items are not all same.
    > > >
    > > > The bit that makes it too hard for me is that there may be blanks, and the
    > > > blanks should not be counted. So:
    > > > A1 = "Duck", B1 = "", C1 = "Duck", D1="Duck" should be a "Yes" in column E.
    > > >
    > > > Thanks very much for any help.
    > > > Daniel
    > > >
    > > >
    > > >


  5. #5
    Daniel Bonallack
    Guest

    RE: Formula help

    This works perfectly - sorry, I now see how I could have just made the column
    to row adjustment myself.

    I confess, I don't really understand the formula, but I guess that doesn't
    matter - thanks very much for providing a solution.

    Daniel


    "Ron Coderre" wrote:

    > Um...OK..You want this:
    > E1: =SUMPRODUCT((A1:D1<>"")/COUNTIF(A1:D1,A1:D1&""))
    >
    >
    > Does that help?
    >
    > ***********
    > Regards,
    > Ron
    >
    >
    > "Daniel Bonallack" wrote:
    >
    > > Hi Ron
    > >
    > > Thanks for offering a solution, but I'm not sure how to apply it. Maybe my
    > > example wasn't clear, but I wasn't sure why you have A1:A10 - I'm trying to
    > > test across the row A1:D1, then copy that formula down to 12,000 rows.
    > >
    > > Hope that clarifies.
    > > Daniel
    > >
    > >
    > > "Ron Coderre" wrote:
    > >
    > > > Try a variation of this:
    > > > E1: =SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10,A1:A10&""))
    > > > That formula counts the number of non-blank, unique items.
    > > >
    > > > Does that help?
    > > >
    > > > ***********
    > > > Regards,
    > > > Ron
    > > >
    > > >
    > > > "Daniel Bonallack" wrote:
    > > >
    > > > > I have a text value in cells A1:D1. Let's say that the values read across
    > > > > the row:
    > > > > A1 = "Duck", B1 = "Duck", C1 = "Cat", D1 = "Duck"
    > > > >
    > > > > I want a formula in cell E1 that will return "No" in this case, meaning that
    > > > > the items are not all same.
    > > > >
    > > > > The bit that makes it too hard for me is that there may be blanks, and the
    > > > > blanks should not be counted. So:
    > > > > A1 = "Duck", B1 = "", C1 = "Duck", D1="Duck" should be a "Yes" in column E.
    > > > >
    > > > > Thanks very much for any help.
    > > > > Daniel
    > > > >
    > > > >
    > > > >


  6. #6
    Ron Coderre
    Guest

    RE: Formula help

    See if this helps with the understanding:

    Using this data:
    A1: DUCK
    B1: DUCK
    C1: (blank)
    D1: CAT

    and the formula =SUMPRODUCT((A1:D1<>"")/COUNTIF(A1:D1,A1:D1&""))

    The (A1:D1<>"") part tests if each cell in A1:D1 is not blank. Each
    non-blank returns a 1, each blank returns a zero. (Actually, it returns TRUE
    and FALSE, but Excel converts them to 1's and 0's)
    Consequently, the example data would return this array: 1,1,0,1

    Next, the COUNTIF(A1:D1,A1:D1&"") section counts how many times it finds
    each cell's value in the range A1:D1.
    Our data would return the array: 2,2,1,1

    So the resulting array divisions would match the items from the first array
    with the items in the second array to get: 1/2, 1/2, 0/2, 1/1

    The SUMPRODUCT function adds all of those values and is only really
    necessary in this example to force Excel to perform array calculations. In
    this case, the total equals 2 unique items.

    You could skip the SUMPRODUCT function and use this formula instead:
    =SUM((A1:D1<>"")/COUNTIF(A1:D1,A1:D1&""))
    ....but you'd need to confirm that array formula by holding down the [Ctrl]
    and [Shift] keys when you press [Enter]. For many people, that's too obscure
    a combination to remember only occaissionally. Hence, I generally prefer the
    SUMPRODUCT function approach.

    I hope that helps?

    ***********
    Regards,
    Ron


    "Daniel Bonallack" wrote:

    > This works perfectly - sorry, I now see how I could have just made the column
    > to row adjustment myself.
    >
    > I confess, I don't really understand the formula, but I guess that doesn't
    > matter - thanks very much for providing a solution.
    >
    > Daniel
    >
    >
    > "Ron Coderre" wrote:
    >
    > > Um...OK..You want this:
    > > E1: =SUMPRODUCT((A1:D1<>"")/COUNTIF(A1:D1,A1:D1&""))
    > >
    > >
    > > Does that help?
    > >
    > > ***********
    > > Regards,
    > > Ron
    > >
    > >
    > > "Daniel Bonallack" wrote:
    > >
    > > > Hi Ron
    > > >
    > > > Thanks for offering a solution, but I'm not sure how to apply it. Maybe my
    > > > example wasn't clear, but I wasn't sure why you have A1:A10 - I'm trying to
    > > > test across the row A1:D1, then copy that formula down to 12,000 rows.
    > > >
    > > > Hope that clarifies.
    > > > Daniel
    > > >
    > > >
    > > > "Ron Coderre" wrote:
    > > >
    > > > > Try a variation of this:
    > > > > E1: =SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10,A1:A10&""))
    > > > > That formula counts the number of non-blank, unique items.
    > > > >
    > > > > Does that help?
    > > > >
    > > > > ***********
    > > > > Regards,
    > > > > Ron
    > > > >
    > > > >
    > > > > "Daniel Bonallack" wrote:
    > > > >
    > > > > > I have a text value in cells A1:D1. Let's say that the values read across
    > > > > > the row:
    > > > > > A1 = "Duck", B1 = "Duck", C1 = "Cat", D1 = "Duck"
    > > > > >
    > > > > > I want a formula in cell E1 that will return "No" in this case, meaning that
    > > > > > the items are not all same.
    > > > > >
    > > > > > The bit that makes it too hard for me is that there may be blanks, and the
    > > > > > blanks should not be counted. So:
    > > > > > A1 = "Duck", B1 = "", C1 = "Duck", D1="Duck" should be a "Yes" in column E.
    > > > > >
    > > > > > Thanks very much for any help.
    > > > > > Daniel
    > > > > >
    > > > > >
    > > > > >


+ 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