+ Reply to Thread
Results 1 to 6 of 6

Countif Based Upon Text Length

  1. #1
    Registered User
    Join Date
    09-17-2003
    Posts
    2

    Countif Based Upon Text Length

    Need a formula that will counta the cell range (A7:A88) and return the number of cells that contain less than 10 characters.

    Example:

    Cell A7 = General Info Intro
    Cell A8 = 1
    Cell A9 = 2
    Cell A10 = 2a

    Desired result would return 3

    Thanks in advance for your expertise!

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    This is a complex criteria (even though it sounds simple).

    There are 2 ways I know of to do this:
    1. use multiple columns
    2. use an array function

    I will explain the multiple columns first.

    In column B (or any empty column) put in the formula:

    =LEN(A7)<10

    And fill down. You will see a bunch of TRUE and FALSE.

    Next, change the formula to (and fill down):

    =(LEN(A7)<10)*1

    Now you will see a bunch of 1 and 0.

    The total you want is the sum of this column.


    To do this in a single formula, you need an Array Formula. Enter this formula:

    {=SUM(1*(LEN(A7:A88)<10))}

    You DO NOT enter the {}. Instead, after typing the formula, rather than pressing Enter, you press Ctrl+Shift+Enter. Excel understands this to mean you want an Array Formula and it enters the {} for you. (Caution: you need to use this same key combination every time you edit the formula.)

  3. #3
    Registered User
    Join Date
    09-17-2003
    Posts
    2
    I was toying with several array formulas and making it more complex than this. Thank you for your fresh set of eyes and expertise! Works great.

  4. #4
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211
    Quote Originally Posted by tralls
    Need a formula that will counta the cell range (A7:A88) and return the number of cells that contain less than 10 characters.

    Example:

    Cell A7 = General Info Intro
    Cell A8 = 1
    Cell A9 = 2
    Cell A10 = 2a

    Desired result would return 3

    Thanks in advance for your expertise!
    =SUMPRODUCT(--(LEN(A7:A88)<10),--(A7:A88<>""))

  5. #5
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Hi TM,

    Why do you use the 2 minus signs? Just to make the formula easier to read?

    Nevermind, I see. I don't yet understand, but I see.

    Now I get it. It's exactly like my multiplying by 1; an algebraic expression is required to resolve TRUE and FALSE to 0 and 1.
    Last edited by MSP77079; 12-23-2006 at 09:09 PM.

  6. #6
    Forum Contributor vikas.bhandari's Avatar
    Join Date
    04-07-2006
    Location
    Delhi, India
    MS-Off Ver
    Office 2007 and 2010
    Posts
    303
    Quote Originally Posted by MSP77079
    Hi TM,

    Why do you use the 2 minus signs? Just to make the formula easier to read?

    Nevermind, I see. I don't yet understand, but I see.

    Now I get it. It's exactly like my multiplying by 1; an algebraic expression is required to resolve TRUE and FALSE to 0 and 1.
    Hello,

    If I am not wrong then "--". It converts the text in the range into 0, 1(binary values) and aallows calculation. You can use the following farmula also :

    =SUM(IF(LEN(A3:A88)<5,1,0))

    Put ctrl+shift+enter after putting the farmula

    Vikas B
    Last edited by vikas.bhandari; 12-26-2006 at 12:44 AM.

+ 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