+ Reply to Thread
Results 1 to 6 of 6

Count number of "1" in a cell

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Count number of "1" in a cell

    Hi,

    Can anyone help me with a formula please that will count the number of 1's in a cell.

    e.g.
    in a cell I may have:
    1010110

    I would need it to return the answer 4

    I have uploaded an example file for reference

    Paul
    Attached Files Attached Files
    Last edited by pauldaddyadams; 12-31-2011 at 08:52 AM.

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count number of "1" in a cell

    Hi

    In a cell(example H1), type the number that you want to count how many times is in Column D.

    In E2 put the Array Formula(CSE)

    =SUM(ISNUMBER(MATCH(TRANSPOSE(MID(D2;ROW(INDEX(D:D;1):INDEX(D:D;LEN(D2)));1));MID(H$1;ROW(INDEX(D:D; 1):INDEX(D:D;LEN(H$1)));1);0))+0)
    Done!

    Hope to helps you.
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  3. #3
    Valued Forum Contributor
    Join Date
    04-21-2005
    Location
    Southern England
    MS-Off Ver
    Excel for Office 365
    Posts
    1,702

    Re: Count number of "1" in a cell

    Perfect - thank you!

    Happy new year!

  4. #4
    Valued Forum Contributor Sadath31's Avatar
    Join Date
    03-02-2011
    Location
    Dammam, Saudi Arabia
    MS-Off Ver
    Office 365
    Posts
    452

    Re: Count number of "1" in a cell

    Hi pauldaddyadams

    YOu have asked to count 1's within a cell
    then use the formula
    =SUMPRODUCT(--((MID(I2,ROW(INDIRECT("1:"&LEN(I2))),1))="1"))
    sorry if I understood wrong.

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Count number of "1" in a cell

    You are welcome

    Happy new Year for you and for your own people!!!

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

    Re: Count number of "1" in a cell

    since they are text just use
    =LEN(D2)-LEN(SUBSTITUTE(D2,"1",""))
    "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

+ 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