+ Reply to Thread
Results 1 to 5 of 5

count if statement

  1. #1
    NYDIA
    Guest

    count if statement

    i have a spreadsheet that is used for a monthly
    attendance. There are codes (p=present, h=hospital stay
    etc). I want to create a formula that will count all the
    p's

    example
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 TOTAL
    john smith p p p p p p h h p p p h h h p p p p 10

    so john was in the program on 10 days of the 5

    can you help me with the formula? Any help is greatly
    appreciated

  2. #2
    Juan Pablo González
    Guest

    Re: count if statement

    Try with

    =COUNTIF(TheRange, "p")

    where TheRange is a reference to the range that contains the p's and h's.

    --
    Regards

    Juan Pablo González

    "NYDIA" <anonymous@discussions.microsoft.com> wrote in message
    news:098e01c50558$764bd7b0$a501280a@phx.gbl...
    > i have a spreadsheet that is used for a monthly
    > attendance. There are codes (p=present, h=hospital stay
    > etc). I want to create a formula that will count all the
    > p's
    >
    > example
    > 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 TOTAL
    > john smith p p p p p p h h p p p h h h p p p p 10
    >
    > so john was in the program on 10 days of the 5
    >
    > can you help me with the formula? Any help is greatly
    > appreciated




  3. #3
    Guest

    Re: count if statement

    I put
    =3DCOUNTIF(D9:H9, "p")
    and it works, but the row may have several different=20
    codes, so i need it to be able to count whether its p or a=20
    or h

    =3Dcountif(d9:h9,"p", "a") doesnt work
    >-----Original Message-----
    >Try with
    >
    >=3DCOUNTIF(TheRange, "p")
    >
    >where TheRange is a reference to the range that contains=20

    the p's and h's.
    >
    >--=20
    >Regards
    >
    >Juan Pablo Gonz=E1lez
    >
    >"NYDIA" <anonymous@discussions.microsoft.com> wrote in=20

    message
    >news:098e01c50558$764bd7b0$a501280a@phx.gbl...
    >> i have a spreadsheet that is used for a monthly
    >> attendance. There are codes (p=3Dpresent, h=3Dhospital stay
    >> etc). I want to create a formula that will count all=20

    the
    >> p's
    >>
    >> example
    >> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 =20

    TOTAL
    >> john smith p p p p p p h h p p p h h h p p p p 10
    >>
    >> so john was in the program on 10 days of the 5
    >>
    >> can you help me with the formula? Any help is greatly
    >> appreciated

    >
    >
    >.
    >


  4. #4
    Nydia
    Guest

    Re: count if statement

    Sorry, my initial said only count the "P", but i know need=20
    it to count all the codes.
    >-----Original Message-----
    >I put
    >=3DCOUNTIF(D9:H9, "p")
    >and it works, but the row may have several different=20
    >codes, so i need it to be able to count whether its p or=20

    a=20
    >or h
    >
    >=3Dcountif(d9:h9,"p", "a") doesnt work
    >>-----Original Message-----
    >>Try with
    >>
    >>=3DCOUNTIF(TheRange, "p")
    >>
    >>where TheRange is a reference to the range that contains=20

    >the p's and h's.
    >>
    >>--=20
    >>Regards
    >>
    >>Juan Pablo Gonz=E1lez
    >>
    >>"NYDIA" <anonymous@discussions.microsoft.com> wrote in=20

    >message
    >>news:098e01c50558$764bd7b0$a501280a@phx.gbl...
    >>> i have a spreadsheet that is used for a monthly
    >>> attendance. There are codes (p=3Dpresent, h=3Dhospital=20

    stay
    >>> etc). I want to create a formula that will count all=20

    >the
    >>> p's
    >>>
    >>> example
    >>> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 =20

    >TOTAL
    >>> john smith p p p p p p h h p p p h h h p p p p =20

    10
    >>>
    >>> so john was in the program on 10 days of the 5
    >>>
    >>> can you help me with the formula? Any help is greatly
    >>> appreciated

    >>
    >>
    >>.
    >>

    >.
    >


  5. #5
    RagDyer
    Guest

    Re: count if statement

    Do you need to count all the codes ... ONE AT A TIME ?

    You could try this:
    Enter in A1, A2, and A3:
    P
    A
    H

    And in B1 enter:
    =COUNTIF($D$9:$H$9,A1)
    And drag down to copy to B3.
    This will give you *individual* counts of your codes.

    If, on the other hand, you want a cumulative count of *all* your codes, you
    could try this:

    =SUM(COUNTIF(D9:H9,{"P","H","A"}))
    --

    HTH,

    RD
    ==============================================
    Please keep all correspondence within the Group, so all may benefit!
    ==============================================


    "Nydia" <anonymous@discussions.microsoft.com> wrote in message
    news:2f8c01c50878$efb87c70$a401280a@phx.gbl...
    Sorry, my initial said only count the "P", but i know need
    it to count all the codes.
    >-----Original Message-----
    >I put
    >=COUNTIF(D9:H9, "p")
    >and it works, but the row may have several different
    >codes, so i need it to be able to count whether its p or

    a
    >or h
    >
    >=countif(d9:h9,"p", "a") doesnt work
    >>-----Original Message-----
    >>Try with
    >>
    >>=COUNTIF(TheRange, "p")
    >>
    >>where TheRange is a reference to the range that contains

    >the p's and h's.
    >>
    >>--
    >>Regards
    >>
    >>Juan Pablo González
    >>
    >>"NYDIA" <anonymous@discussions.microsoft.com> wrote in

    >message
    >>news:098e01c50558$764bd7b0$a501280a@phx.gbl...
    >>> i have a spreadsheet that is used for a monthly
    >>> attendance. There are codes (p=present, h=hospital

    stay
    >>> etc). I want to create a formula that will count all

    >the
    >>> p's
    >>>
    >>> example
    >>> 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

    >TOTAL
    >>> john smith p p p p p p h h p p p h h h p p p p

    10
    >>>
    >>> so john was in the program on 10 days of the 5
    >>>
    >>> can you help me with the formula? Any help is greatly
    >>> appreciated

    >>
    >>
    >>.
    >>

    >.
    >



+ 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