+ Reply to Thread
Results 1 to 11 of 11

return numbers in a cell based upon words count in a cell

Hybrid View

  1. #1
    Registered User
    Join Date
    03-08-2014
    Location
    islamabad, pakistan
    MS-Off Ver
    Excel 2007
    Posts
    35

    Exclamation return numbers in a cell based upon words count in a cell

    Hello.
    i am in urgent need of help. I basically need a formula that would return the values in Column G automatically rather than manually posting them. Criteria is based on the number of letters in Column A.
    For Example in cell A2 there is only 1 letter so i want to return in an empty cell (say column H) 1. A3 has 3 letter so i want it to return 2. A4 has 6 letters so i want it to return 3.
    These 1,2,3... are levels based on how many letters or characters are there in Column A. As they increase so does the level. I have attached the excel sheet. Kindly help.
    Attached Files Attached Files

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: return numbers in a cell based upon words count in a cell

    Enter formula in G2 and copy down
    Formula: copy to clipboard
    =LEN(SUBSTITUTE(A2,"0",""))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: return numbers in a cell based upon words count in a cell

    It looks like you want to count non-zero characters in the cell.

    If so, try this:

    =LEN(SUBSTITUTE(A2,0,""))

    Copy down as needed.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  4. #4
    Registered User
    Join Date
    03-08-2014
    Location
    islamabad, pakistan
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: return numbers in a cell based upon words count in a cell

    Thank you Alkey and Tony. Yes it worked for me. Thanks a lot once again.
    I need to know one thing if you may help. 101002000. Suppose we have this number. I need formula to return this number series by deleting all the zeros that appear to the right side i.e. 101002.
    Can you help me with this?

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: return numbers in a cell based upon words count in a cell

    For something like this you also use SUBSTITUTE function to remove "000"
    Formula: copy to clipboard
    =SUBSTITUTE(A1,"000","")

    v A B
    1 101002000 101002

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,747

    Re: return numbers in a cell based upon words count in a cell

    I interpreted a little differently. This removes all zeroes to the right of the last non-zero number.

    It must be array entered.
    Formula: copy to clipboard
    =REPLACE(A1,MAX(ISNUMBER(1/MID(A1,ROW($1:$25),1))*ROW($1:$25))+1,99,"")
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.


    Row\Col
    A
    B
    C
    1
    101002000
    101002 In B1 =REPLACE(A1,MAX(ISNUMBER(1/MID(A1,ROW($1:$25),1))*ROW($1:$25))+1,99,")
    2
    1010020
    101002 And fill down.
    3
    10100200000
    101002
    4
    101001000
    101001
    5
    1010010
    101001
    6
    10100700000
    101007
    7
    101002000
    101002
    Dave

  7. #7
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,179

    Re: return numbers in a cell based upon words count in a cell

    Or try this ...

    =LOOKUP(2,1/(MOD(A1/10^(ROW($1:$25)-1),1)=0),A1/10^(ROW($1:$25)-1))
    Last edited by Phuocam; 06-19-2016 at 03:33 AM.

  8. #8
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2024
    Posts
    6,179

    Re: return numbers in a cell based upon words count in a cell

    Another way ...

    =LEFT(A1,AGGREGATE(14,6,ROW($1:$25)/(--MID(A1,ROW($1:$25),1)>0),1))
    Last edited by Phuocam; 06-19-2016 at 04:12 AM.

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: return numbers in a cell based upon words count in a cell

    Using ROW($1:$25) leaves the formula vulnerable to new row insertions.

    ROW(INDIRECT("1:"&LEN(A1))) would be more robust.

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,747

    Re: return numbers in a cell based upon words count in a cell

    @ Tony

    Yes. Or the non-volatile

    ROW(INDEX(A:A,1):INDEX(A:A,LEN(A1)))
    Last edited by FlameRetired; 06-19-2016 at 02:24 PM.

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: return numbers in a cell based upon words count in a cell

    Here is another way to remove trailing zeros
    Formula: copy to clipboard
    =--SUBSTITUTE(--("."&A1),".","")

    v A B
    1 10102000 10102
    2 101020300400000 1010203004
    3 4560654000 4560654
    4 12345 12345

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 8
    Last Post: 05-20-2015, 10:25 AM
  2. [SOLVED] Return cell count based on multiple values (and data validation)
    By Reapz in forum Excel General
    Replies: 3
    Last Post: 01-10-2014, 06:05 AM
  3. [SOLVED] Break Cell based on character count-w/o splitting words-Help
    By mnfez in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-19-2013, 09:05 AM
  4. [SOLVED] Count amount of desired numbers in a single cell and return that value in another cell
    By jmallory76 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-20-2013, 10:09 AM
  5. Replies: 1
    Last Post: 01-25-2013, 04:59 PM
  6. Replies: 3
    Last Post: 12-21-2012, 05:33 AM
  7. Count words-I want a function that can count the words in a cell
    By wilhelm in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-19-2009, 03:41 PM

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